Fore more QTP Realtime scripts, visit www.ramupalanki.

com
Function obj_UDF_getRecordset (strFileName, strSQLStatement) Dim objAdCon, objAdRs Set objAdCon = CreateObject(“ADODB.Connection”) objAdCon.Open “DRIVER={Microsoft Access Driver (*.mdb)};DBQ=”&strFileName & “;Readonly=True” If Err 0 Then Reporter.ReportEvent micFail,”Create Connection”, “[Connection] Error has occured. Error : ” & Err Set obj_UDF_getRecordset = Nothing Exit Function End If Set objAdRs = CreateObject(“ADODB.Recordset”) objAdRs.CursorLocation=3 ‘ set the cursor to use adUseClient – disconnected recordset objAdRs.Open strSQLStatement, objAdCon, 1, 3 While objAdRs.EOF=false For i=0 to 4 msgbox objAdRs.fields(i) Next objAdRs.moveNext Wend If Err0 Then Reporter.ReportEvent micFail,”Open Recordset”, “Error has occured.Error Code : ” & Err Set obj_UDF_getRecordset = Nothing Exit Function End If Set objAdRs.ActiveConnection = Nothing objAdCon.Close Set objAdCon = Nothing Set obj_UDF_getRecordset = objAdRs End Function Set rsAddin = obj_UDF_getRecordset(“C:\Documents and Settings\mohank\Desktop\Login.mdb”, “Select * from Login”)

Sign up to vote on this title
UsefulNot useful