[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

vbscript to connect to access db

Posted on 2004-09-10
6
Medium Priority
?
427 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:barryk2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 12030667
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
0
 

Author Comment

by:barryk2
ID: 12030702
Leon,

I  really was looking for some code that is straight vbs no asp or server.
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 12030976
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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:barryk2
ID: 12031208
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?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 12031578
You just need CreateObject("ADODB.Connection").  Obviously Server.CreateObject makes no sense, cos the scripting runtime doesn't know what a Server is.

Hope this helps.
0
 
LVL 10

Expert Comment

by:anv
ID: 12033920
though carl_tawn has given the answer

still for further reference u can chek this link

http://www.experts-exchange.com/Programming/Q_20643048.html
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question