Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

WinRunner: How to connect to ORACLE Database without TNS?
The following code would help the above problem.

tblName = getvar("curr_dir")&table;
ddt_close_all_tables();
resConnection = "";
db_disconnect("session");
rc = ddt_open(tblName, DDT_MODE_READ);
if (rc != E_OK)
pause("Unable to open file");
else
{
dvr = ddt_val(tblName,"DRIVERNAME");
tnsName = ddt_val(tblName,"SERVER");
user = tolower(ddt_val(tblName,"UID"));
pass = tolower(ddt_val(tblName,"PWD"));
host = ddt_val(tblName,"HOSTNAME");
port = ddt_val(tblName,"PORT");
pro = toupper(ddt_val(tblName,"PROTOCOL"));
resConnection = db_connect("session", "driver="dvr";Database="tnsName";hostname="host";port="port";protocol="pro";
uid="user"; pwd="pass";");
if (resConnection != 0)
{
report_msg("There is a problem in connecting to the Database = "&tnsName&", Check it please..");
treturn;
}
else
{
report_msg("Connection to the Database is successful..");
rsEQ1 = db_execute_query("session","your database query",record_number1);
}
db_disconnect("session");
}
 
     How to use this :  Assume we have saved the script in 
       c:winrunner as dbconnect
            Save data table at same location, ie c:winrunner as dbdetails.xls
                 give call to dbconnect from other script which aslo saved at same location
c:winrunner as ==>call dbconnect("dbdetails.xls");
                Because the above script is using getvar("curr_dir") function to get the current directory, looks at the same location for data table.