Hi i want to open a mdb file(microsoft acess ) from the specified location and i want to validate various data inthe data base.How to do that plzzzz can any one tell?like for excel sheet we use createobject("excel.application")??

Questions by sriprakash_hebbar

Showing Answers 1 - 3 of 3 Answers

Jayalakshmi

  • Dec 20th, 2006
 

VBScript - file to open the Database and verifies the value(passed from the QTP) exists in the Table or not and returns the Boolean value to the QTP script, whether passed value exist in table or not -

DbDemo (VBScript File Name) -

Public function DbDemo(param1) 

Dim Cnxn, strCnxn
Dim rsCustomers, strSQLCustomers
Dim fld, Err

Set Cnxn = CreateObject("ADODB.Connection")

Set rsCustomers = CreateObject("ADODB.RecordSet")

strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Program FilesMercury InteractiveQuickTest Professionalsamples lightapp light32.mdb;User Id=admin;Password=;"
            Cnxn.Open strCnxn

MsgBox "connected"

strSQLCustomers = "select * from orders where customer_name ='" & param1 & "'"

rsCustomers.Open strSQLCustomers, Cnxn

If rsCustomers.recordcount > 0 Then
       DbDemo =  "True"
Else
        DbDemo =   "False"
End If
Cnxn.Close

End function

QTP Script -

Dim CustName, NameExist

ExecuteFile "...DbDemo.vbs" 'Declaring the VBscript File

CustName = DataTable("Customer_Name",dtGlobalSheet) 'Getting the value(Customer Name) from the DataTable 

NameExist = DbDemo(CustName) 'Passing the value to VB script file and getting the Boolean value, whether Customer Name is exist in table or Not -

if(NameExist == "True")

MsgBox "Customer Name is Exist in Table"

else

MsgBox "Customer Name is Not Exist in Table"

Endif

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions