ADO connection with VBS to locally stored MS-Access database

From: Peter Wetschnigg (pwetsch_at_gmx.at)
Date: 02/25/05


Date: Fri, 25 Feb 2005 22:59:44 +0100

Hello

I am trying to connect to a local Access database via ADO and VB Script.
The following code snippet is supposed to connect to a database and show
the number of records in table1 in a message box

----------------------------------------

<script type="text/vbscript">

Dim oRS
Dim oConn
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" & _
           "DBQ=C:\MyDatabase.mdb;"

oRS.Open "Select * FROM table1", oConn

MsgBox oRs.RecordCount

oConn.Close
Set oConn = Nothing
</script>

----------------------------------------

But, when I load the html-document which contains this code into Iexplorer,
it crashes. :-( The database must have been opened, because a .ldb has been
created, which remains on the hard disk after the crash, but there still
must be a mistake in the oConn.Open statement. Could anyone give me an
advice?

Best regards,
Peter W.



Relevant Pages

  • Pull method for sqlceremotedataaccess
    ... catch (SqlCeException ce) ... private static void CreateDatabase() ... // Pull down the authors table from the pubs database on the remote ... internetUrl in the code snippet without any error ...
    (microsoft.public.sqlserver.ce)
  • pull method
    ... catch (SqlCeException ce) ... private static void CreateDatabase() ... // Pull down the authors table from the pubs database on the remote ... internetUrl in the code snippet without any error ...
    (microsoft.public.sqlserver.replication)
  • Re: Populate dataset with text file
    ... I have found this code snippet on about.com, but it does not work for me ... Connect a TADOCommand to your database using the ConnectionString or the ... >> populate a memo control in less than a second. ...
    (borland.public.delphi.database.ado)
  • Re: import from text file, change rowstate
    ... > means they won't add to the database during dataadapter.update. ... Can someone toss me a code snippet? ... > 1) Change connection on the dataadapter to my Access database ...
    (microsoft.public.dotnet.framework.adonet)
  • import from text file, change rowstate
    ... Can someone toss me a code snippet? ... database is never updated because all rows are ... Change connection on the dataadapter to my Access database ...
    (microsoft.public.dotnet.framework.adonet)