barryk2
asked on
vbscript to connect to access db
Hello I am wondering if it is possible to connect to a db and perform operations froma standalone vbscript. I typically run these vbs files from the command line and it seems this is possible but everythings I have tried in my code does not work. I have used asp and vbscript to connect to access or sql server databases. I have created an odbc link to a db but thats about as far as I have gotten.
ASKER
Leon,
I really was looking for some code that is straight vbs no asp or server.
I really was looking for some code that is straight vbs no asp or server.
Try this:
set conn=Server.CreateObject(" ADODB.Conn ection")
conn.Provider="Microsoft.J et.OLEDB.4 .0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("AD ODB.record set")
rs.Open "Select Count(*) From Customers", conn
MsgBox "Where are " & rs(0).Value & " records in the table"
Leon
set conn=Server.CreateObject("
conn.Provider="Microsoft.J
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("AD
rs.Open "Select Count(*) From Customers", conn
MsgBox "Where are " & rs(0).Value & " records in the table"
Leon
ASKER
Ran your code:
VBScript Runtime Error: Object Required: 'Server'
I have used similar code when connecting to db's through asp & vbscript but just running vbscript alone I cannot seem to find what to put in the place of Server.CreateObject etc...
Any Ideas?
VBScript Runtime Error: Object Required: 'Server'
I have used similar code when connecting to db's through asp & vbscript but just running vbscript alone I cannot seem to find what to put in the place of Server.CreateObject etc...
Any Ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
though carl_tawn has given the answer
still for further reference u can chek this link
https://www.experts-exchange.com/questions/20643048/VBScript-in-WSH-and-a-little-Database.html
still for further reference u can chek this link
https://www.experts-exchange.com/questions/20643048/VBScript-in-WSH-and-a-little-Database.html
http://www.w3schools.com/ado/default.asp
Here is where you will find your connection strings:
http://www.able-consulting.com/ADO_Conn.htm
Leon