Skip to main content

Posts

Showing posts with the label DB Automation

Working with BLOB or CLOB Objects in QTP

The below Code will Insert the CLOB or BLOB objects in  Oracle DB using QTP. Sample Code: 'CLOB or BLOB file Path strClobFileName = "C:\Jay\SampleInputs\BLOBorCLOB.txt" 'Connection String strOracleConnectionString =  "Driver= {Microsoft ODBC for Oracle}; " &_                   "ConnectString=(DESCRIPTION=" &_                   "(ADDRESS=(PROTOCOL=TCP)" &_                   "(HOST=hostName) (PORT=1234))" &_                   "(CONNECT_DATA=(SERVICE_NAME=ABCD)));uid=userName; pwd=Password;" 'Create Required Objects Set objCon = CreateObject("Adodb.Connection") Set objRs = CreateObject("Adodb.Recordset") Set objCom = CreateObj...

Getting Record Count Using ADODB Connection in QTP

When you get the Record Count as  -1 Change the CursorLocation to 3 or 2 or 1(mostly 3 ll work) Sample Code:  strConnectionString =  "Driver= {Microsoft ODBC for Oracle}; " &_                   "ConnectString=(DESCRIPTION=" &_                   "(ADDRESS=(PROTOCOL=TCP)" &_                   "(HOST=hostName) (PORT=1234))" &_                   "(CONNECT_DATA=(SERVICE_NAME=ABCD)));uid=userName; pwd=Password;" strQuery = "Select * From Table" Set objCon = CreateObject("Adodb.Connection") objCon.CursorLocation = 3 Set objRs = CreateObject("Adodb.Recordset")  objCon.Open strConnectionString Set objRs = objCon.Exe...

Read Data From Sql DB

'The name of Server strCurrentEnv = "MyServername\JaySQL" 'The name of your database: dbName = "qtpDemo" 'SQL Server connection string(you need to enter your username and password) strConnection = "DRIVER={SQL SERVER}; Server=" & strCurrentEnv & "; DATABASE="& dbName& ";uid=sa; pwd=" Set conn = CreateObject("ADODB.Connection") conn.Open strConnection 'The SQL you want to run query = "Select * from dbo.hpTools" Set rs = conn.Execute(query) dbResults = rs.GetString print dbResults

Database Connection Strings For Sql, Oracle and Excel

Database Connection Strings For Sql, Oracle and Excel 'For Oracle Db strOracleConnection   = "provider=oraoledb.1;server=localhost;uid=scott;pwd=tiger;database=testdata" 'For Sql DB strSqlConnection=  "provider=sqloledb.1;server=localhost;uid=sa;pwd=;database=testdata" 'For Excel strExcelConnection = "DRIVER={Microsoft Excel Driver (*.xls)};DBQ=C:\Jay.xls;Readonly=True"