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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client side script posting to database

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
I have been working on a basic asset management app whereby an .ASP page is loaded at login and the webserver then uses WMI to retrieve information about the PC (memory, speed etc.) I also use session variables such as hostname and username which also get posted in the database.

The problem I have run into is that if there is a DNS problem then the script will not run. I have set up scavenging to keep the DNS records more up to date but there are still times when the odd PC slips through the net.

I would like to gather all the information clientside then post that but I don't know how to connect to the database. In ASP it would be:

<%

Set DB = Server.CreateObject("ADODB.Connection")
Set TBL = Server.CreateObject("ADODB.RecordSet")

DB.Mode = adModeReadWrite
DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("../directory/userdb.mdb"))

TBL.Open "INSERT INTO Names (FirstName, Surname) VALUES ('Ed', 'Mozley')", DB

Set TBL=Nothing
Set DB=Nothing

%>

Is it possible to do something similar in vbscript and if so what would be the equivalent? I think once I've got the basics all the other WMI stuff should fall into place.

Thanks very much

Ed
 
SET conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
SET rs = Server.CreateObject("ADODB.Recordset")

rs.Open "SELECT * FROM Names",conn
sql="INSERT INTO Names (FirstName, Surname) VALUES ('Ed', 'Mozley')"
conn.Execute sql
rs.Close
conn.Close
 
If I try and run this as a clientside .vbs file I get the error

Object Required 'Server'
 
To run this "clientside" you will just need to change the two SET lines to:

SET conn = CreateObject("ADODB.Connection")
SET rs = CreateObject("ADODB.Recordset")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top