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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

how do u plan test automation?

1536


Why script error occur in between recording in qtp?

1860


iam have done mba(finance)in 2008. in 2008 one reputed consultancy came off campus interview our institution. i got job as "manual test engineer". now iam working as "manual testing engineer". now my problem is when iam going interview the interviewer asking like " ur mba gradute how can u get job in test engineer." this question i have faced every interview. iam explaining how iam getting job. but they are not trust me". pls tell me answer how i am giving relavent ans.. this is my mail id y.ramana84@gmail.com

1489


in data driven testing for performing operations which method is easy from manual test data,keyword view,or from database.and why?

1447


Write a QTP script to enter a keyword in to Google search engine?

747






Will down time for server and content maintenance/upgrades be allowed? how much?

710


How to do the scripting. Is there any inbuilt functions in qtp as in qtp-s.

631


Will there be any standards or requirements for page appearance and/or graphics throughout a site or parts of a site?

698


Pls can anybody send me the Recent Technical and Interview Questions Which were asked in IBM(QTP)Automation PLZZZZZZZZZ

1641


What will be happen if i load object repository at run time, but it has already associated.

1358


In application which areas to be automated and what kind of situation will be take? using QTP? Plz give me the clear answer

2027


How can you identify the browser and its information using QTP script?

636


How to recognise the webelement and verifying that webelement is enabled?

1733


How to modify the text checkpoint?

698


How to use the object spy in quicktest professional 8.0 version?

628