Micro Focus QTP (UFT) Forums
how to connect My SQL - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: how to connect My SQL (/Thread-how-to-connect-My-SQL)



how to connect My SQL - kandula - 09-24-2010

Please tell me how to connect to mysql


RE: how to connect My SQL - Jyobtech - 09-24-2010

Hi Kandula,

Since elements (links, data etc) on web page sometime are floating, so we need to select from database.

Here I have made a paragraph of statement for DB connection and data selecting, and I have successfully connected with WEBDEV database. FYI.



****************************************************************************************

Code:
Set Conn = CreateObject("ADODB.Connection" )

str="DRIVER={MySQL ODBC 3.51 Driver};SERVER=webdev;DATABASE=intranet;user id=root ; password=xxxxx"

Conn.open str

Set Rs = CreateObject ("ADODB.Recordset" )

sql = "select * from `user`;"

Rs.open sql,conn,1,3

If (not Rs.eof) then

Rs.MoveFirst

' show the first piece of record from user table'

MsgBox Rs(0)

MsgBox Rs(1)

MsgBox Rs(2)

MsgBox Rs(3)

MsgBox Rs(4)

MsgBox Rs(5)

MsgBox Rs(6)

end if

Rs.close

Set Rs = Nothing

Conn.close

Set Conn = Nothing