Connect to mysql 5.0 database using pure vbscript?

风格不统一 提交于 2019-11-28 12:24:18
Anton Hansson

Install MySQL Connector/ODBC and use a connection string like the following

connectionString = "Driver={MySQL ODBC 5.1 Driver};Server=yourServerAddress;" & _
                   "Database=yourDataBase;User=yourUsername;" & _
                   "Password=yourPassword;"
Venu Gopi

I made small changes to the above script and is working fine:

dim cn, rs

i = 0

set cn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")

connectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;" & _
                   "Data Source=dsn_hb; Database=TP; User=root; Password=***;"

cn.Open connectionString
rs.open "select * from test.Login", cn, 3
rs.MoveFirst

'msgbox rs(0)'

while not rs.eof
    msgbox rs.Fields(0)
    rs.MoveNext
wend

cn.close

MsgBox "End of program"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!