How do you connect to database ,What is the script to
connect DATA BASE?

Answers were Sorted based on User's Feedback



How do you connect to database ,What is the script to connect DATA BASE? ..

Answer / sandipgami84

u need to put above code in "GetSQLData" Function

Is This Answer Correct ?    3 Yes 1 No

How do you connect to database ,What is the script to connect DATA BASE? ..

Answer / sandipgami84

u need to installed "mysql-connector-odbc-3.51.27-win32",
then write down below code,

Dim objCon, ObjRecordSet
ConnString = "Driver=MySQL ODBC 3.51 Driver; server=ServerIP"
ConnString = ConnString &";database=DBName"
ConnString = ConnString &";user=DBusername"
ConnString = ConnString &";password=DBPassword"
Set objCon = createobject("ADODB.Connection")
objCon.Open(ConnString)
Set ObjRecordSet = CreateObject("ADODB.Recordset")
ObjRecordSet.Open CStr("Select * From tbName Where Id =
'1'),objCon
If (not ObjRecordSet.EOF) then
For I = 0 To ObjRecordSet.Fields.Count - 1
If I = 0 Then
On Error Resume Next
GetSQLData = Trim(Cstr(ObjRecordSet.Fields(I)))
Else
On Error Resume Next
GetSQLData = Trim(CStr(GetSQLData)) & "," &
Trim(CStr(ObjRecordSet.Fields(I)))
End If
Next
End If
ObjRecordSet.close
objCon.close
Set ObjRecordSet = Nothing
Set objCon = Nothing
DataBaseConnection = GetSQLData
GetSQLData = ""




-----------
Sandip Gami
+91-9714177088

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More QTP Interview Questions

What is a programmatic description?

0 Answers  


what is defination of regression testing?

3 Answers  


Tell me few important difference Between QTP and WinRunner?

3 Answers   Syntel,


what is the difference between DP and keyword driven framework?

1 Answers  


can u write Script to do Data Driven Testing throuh Externel & internel XL Sheet

2 Answers   Relq,


What type of error u will get if u have not installed java add in in java project? what is the error name ?

1 Answers   Verizon,


For Data-Driven testing can you use micro soft word document instead of using Datatable what is your approach?

0 Answers   Nokia,


What all challenges you have faced during automation and how you have resolved it?

2 Answers   Genpact,


How To write script in QTP For Field Validation Example: password Field is accepting A range 8-20 characters only.How to write script?

3 Answers  


How to convert non-reusable action into reusable action in QTP?(i know by default QTP will take it as a non-reuable action )(Chandana) plz urgent?

4 Answers   Wipro,


How to create basic scripts from a manual test case in QTP?

1 Answers  


Syntax for how to call one script from another and Syntax to call one "Action" in another?

1 Answers   Crea,


Categories