Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to MySQl from a VBS Script

Status
Not open for further replies.

Herivelton

Systems Engineer
Dec 11, 2018
1
BR
Dear,
Please, I need from a .VBS file (inventory.vbs) to connect to a MySQL Database on my local network, but I do not know how to do this, could you help me?

MySQL Server IP: 192.168.30.5
Login: root
Password: 1234
Door: 3306

I tried the following but it does not work:


Code:
Dim rs, strConnectString, strSQL 

Set rs = CreateObject("ADODB.Recordset") 

strConnectString = "DRIVER={MySQL ODBC 3.51 Driver};Server=192.168.30.5;UID=root;Password=1234;Database=invetario;Option=3" 

rs.ActiveConnection = strConnectString 

strSQL = "INSERT INTO equipamento (hostname, dt_ultimoLogin) VALUES ('UIT-TI06', now()) ON DUPLICATE key update dt_ultimoLogin = now();" 

rs.Open strSQL 

Wscript.Quit

When I run the "Inventory.vbs" file, an MS-Windows window appears with the following error message:

Error_jxc5im.png


Line 29 to which the error message refers is:

Code:
rs.ActiveConnection = strConnectString

Just as observation, the MySQL server is hosted on a "Linux - Ubuntu".


At first, for testing purposes only, I'm trying to write only basic information in the database, but as soon as it works, I'll enter a lot of other information.

I will upload the "Inventory.vbs" file together with the Windows Server 2008 Logon Script. This way, whenever the user logs in, the Hardware and Software information will be updated in the Database.

The goal is just to take inventory of hardware and software.


My name is Herivelton, I am from Brazil and my level of fluence in English Language is not very high, so I apologize for any errors in the spelling or in the text.

Thanks to whoever can help me ...

Herivelton
herfranpi@gmail.com
 
Check in ODBC Data source administrator 32 bit to see if the driver is indeed installed.

David Paulson

 
forum329

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top