当前位置:网站首页>Connecting MySQL database with VBScript_ Old bear passing by_ Sina blog

Connecting MySQL database with VBScript_ Old bear passing by_ Sina blog

2022-06-25 23:54:00 wenroudelang8888

1. Installation is required first mysql-connector-odbc-3.51.15-win32.msi( The next step between the installation process )
(PS: It should be noted that odbc yes 32 A still 64 Bit depends on your computer / On the remote computer mysql yes 32 A still 64 position , It doesn't depend on your computer system )

Open the control panel  --》  Management tools
 utilize VBScript Connect mysql database  


double-click   data source (ODBC)
 utilize VBScript Connect mysql database  

Click on   add to
 utilize VBScript Connect mysql database  


choice mysql odbc 5.1 driver  --》  Click finish
 utilize VBScript Connect mysql database  

Fill in data source name (DSN), Later in the program, we will use
Fill in server Address , It's usually localhost,  If it is a remote computer, fill in the remote address
Fill in   user name 、 password 、 Database name    --》  Click test
 utilize VBScript Connect mysql database  

If the test is successful , be odbc Setup complete , Click on ok Complete data source addition
 utilize VBScript Connect mysql database   utilize VBScript Connect mysql database



2. And this is where vbs The program uses
Const USERNAME = "root"
Const PASSWORD = "12345"
Const strConn = "dsn=mysql;driver={MySQL ODBC 5.1 Driver};

    server=localhost;uid="&USERNAME&";pwd="&PASSWORD&";database=test;port=3306;"

Set conn = CreateObject("adodb.connection")
conn.Open strConn

Set rs = CreateObject("adodb.recordset")
rs.Open ssql, conn, 1, 3
rs.MoveFirst

Do Until rs.EOF
     WScript.Echo rs.Fields("name")
     rs.MoveNext
Loop

rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing

' Display the data
' set rs=server.CreateObject("adodb.recordset")
' sql="select * from zhu_sql where i=2;"
' rs.open sql,conn,1,1

' Other increase 、 Delete 、 Change
'conn.execute(sql)


Problems encountered :

Microsoft OLE DB Provider for ODBC Drivers (3, 1) : [Microsoft][ODBC  Driver manager ]  At the designated  DSN  in , Architecture mismatch between driver and Application   


This is because I installed mysql yes 32 position But I installed odbc yes 64 position Of , Just install 32 Bit odbc Or install 64 Bit mysql that will do  !

原网站

版权声明
本文为[wenroudelang8888]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206252107002608.html