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

How to identify the child window. In my case while recording, When i open new window and give checkpoint for some control and when i run that script QTP give error like" can not identify the object" Is there any method or solution to handle child window issue Note: In my apllication i have to check child window of child window also ( multiple windows open )

2 Answers   Infovision,


Can we test GUI of the application using QTP.? How.?If possible briefly explain process.?

1 Answers   Wipro,


suppose by navigation i went from 1st page to 5th page write a script for coming from any page to the 1st page abd by executing where the page may be . it will come to 1st page give the code using gmail. give me mail id so that i can under this answer with out any doubt

1 Answers  


.have you ever written compiled module? if yes , tell me about some of the function that you wrote.

0 Answers   TCS,


How can we change(increase or decrease)the size of a array variable with out loosing the previous values

1 Answers   DST Global Solutions,






How does Parameterization and Data-Driving relate to each other in QTP?

2 Answers  


While writing script using For Next Statement in QTP, I try defining the variable in Lib File I am getting syntax error whereas if I use the variable in script file, the script works fine. Can anyone help me in finding the reason behind this?. E:g Dim intStartRow (Define in Lib File----- say abc.vbs) Dim intRow (If I define this variable in Lib file I am getting Syntax error where as if I define in the script file ---- say xyz.mts the script works fine) IntStartRow=2 For intRow = intStartRow to xlWrksht.UsedRange.Rows.Count ‘Some Code here Next

1 Answers  


Which MS Excel formulas are possible to use in the DataTable? I am searching a formula for searching a field in the datatable

3 Answers   HP,


What is accessibility check point?

0 Answers  


how to test power point using QTP 8.2 ? What are different methods to retrieve value from Application during runtime ?

3 Answers   HCL,


How u perform exception handling in QTp,what is other name for ths

1 Answers   Lehman Brothers,


How do you do batch testing in wr and is it possible to do in qtp, if so explain?

0 Answers  


Categories