Link to home
Start Free TrialLog in
Avatar of barryk2
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.
Avatar of leonstryker
leonstryker
Flag of United States of America image

Here is an ADO tutorial which shows how it works from ASP (using VBS)

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
Avatar of barryk2
barryk2

ASKER

Leon,

I  really was looking for some code that is straight vbs no asp or server.
Try this:

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select Count(*) From Customers", conn
MsgBox "Where are " & rs(0).Value & " records in the table"

Leon

Avatar of barryk2

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?
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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