Opening an Access database with ADO connection and VBScript 
Author Message
 Opening an Access database with ADO connection and VBScript

I have a Access Database called 'db_scrath' saved to
the "C:\TEMP\db_scratch.mdb" directory. It has the
fields "ID" and "test_field" in it. I just want to read
the database and export it to an webpage using VBScript
and ASP's. I have this code so far:

<html>

<%
Dim conAuto  'ADO Connection
Dim recAuto  'ADO Recordset
Dim strDBPath 'Path to your Access DB

'Set path to the Access data base
strDBPath = "C:\TEMP\db_scratch.mdb"

'Creates the ADO connection
Set conAuto = Server.CreateObject("ADODB.Connection")

'Accesses the database
conAuto.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & strDBPath &";"

Set recAuto = cnnAuto.Execute("SELECT * FROM scratch")
%>
        <table border = "2">
<%
        Do While Not recAuto.EOF
                %>
                <tr>
                        <td>Testing</td>
                        <td><%= recAuto.Fields("id").Value
%></td>
                        <td><%= recAuto.Fields
("test_field").Value %></td>
                        <td>4th box</td>
                </tr>
<%           recAuto.MoveNext
        Loop
%>
</table>
        <%
recAuto.Close
Set recAuto = Nothing
conAuto.Close
Set conAuto = Nothing
%>

</html>

It doesn't pring out any of the data from the database.
Not sure what is wrong here...any help is a huge bonus.
Thanks.



Sat, 27 Nov 2004 03:43:48 GMT  
 Opening an Access database with ADO connection and VBScript
Your error is in your SQL string;
SELECT * FROM scratch
If I understand correcty "scratch" is the name of your database.
It should read like:
SELECT ID, test_field FROM tablename

Yuri


Quote:
> I have a Access Database called 'db_scrath' saved to
> the "C:\TEMP\db_scratch.mdb" directory. It has the
> fields "ID" and "test_field" in it. I just want to read
> the database and export it to an webpage using VBScript
> and ASP's. I have this code so far:

> <html>

> <%
> Dim conAuto  'ADO Connection
> Dim recAuto  'ADO Recordset
> Dim strDBPath 'Path to your Access DB

> 'Set path to the Access data base
> strDBPath = "C:\TEMP\db_scratch.mdb"

> 'Creates the ADO connection
> Set conAuto = Server.CreateObject("ADODB.Connection")

> 'Accesses the database
> conAuto.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=" & strDBPath &";"

> Set recAuto = cnnAuto.Execute("SELECT * FROM scratch")
> %>
> <table border = "2">
> <%
> Do While Not recAuto.EOF
> %>
> <tr>
> <td>Testing</td>
> <td><%= recAuto.Fields("id").Value
> %></td>
> <td><%= recAuto.Fields
> ("test_field").Value %></td>
> <td>4th box</td>
> </tr>
> <% recAuto.MoveNext
> Loop
> %>
> </table>
> <%
> recAuto.Close
> Set recAuto = Nothing
> conAuto.Close
> Set conAuto = Nothing
> %>

> </html>

> It doesn't pring out any of the data from the database.
> Not sure what is wrong here...any help is a huge bonus.
> Thanks.



Sat, 27 Nov 2004 04:16:21 GMT  
 Opening an Access database with ADO connection and VBScript
Is that your actual code, cut-and-paste into the message?

If so, you've got a typo: you have Set recAuto = cnnAuto.Execute("SELECT *
FROM scratch") instead of Set recAuto = conAuto.Execute("SELECT * FROM
scratch")

(cnnAuto vs. conAuto)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele


Quote:
> I have a Access Database called 'db_scrath' saved to
> the "C:\TEMP\db_scratch.mdb" directory. It has the
> fields "ID" and "test_field" in it. I just want to read
> the database and export it to an webpage using VBScript
> and ASP's. I have this code so far:

> <html>

> <%
> Dim conAuto  'ADO Connection
> Dim recAuto  'ADO Recordset
> Dim strDBPath 'Path to your Access DB

> 'Set path to the Access data base
> strDBPath = "C:\TEMP\db_scratch.mdb"

> 'Creates the ADO connection
> Set conAuto = Server.CreateObject("ADODB.Connection")

> 'Accesses the database
> conAuto.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=" & strDBPath &";"

> Set recAuto = cnnAuto.Execute("SELECT * FROM scratch")
> %>
> <table border = "2">
> <%
> Do While Not recAuto.EOF
> %>
> <tr>
> <td>Testing</td>
> <td><%= recAuto.Fields("id").Value
> %></td>
> <td><%= recAuto.Fields
> ("test_field").Value %></td>
> <td>4th box</td>
> </tr>
> <% recAuto.MoveNext
> Loop
> %>
> </table>
> <%
> recAuto.Close
> Set recAuto = Nothing
> conAuto.Close
> Set conAuto = Nothing
> %>

> </html>

> It doesn't pring out any of the data from the database.
> Not sure what is wrong here...any help is a huge bonus.
> Thanks.



Sat, 27 Nov 2004 06:14:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. error doing a FILTER on an Access database via Asp/VBScript and ADO

2. error doing a FILTER on an Access database via Asp/VBScript and ADO

3. database connection remain open if opened via recordset

4. ADO Database connection open or closed?

5. Problem opening ADO connection to database on a CDROM

6. When to open ADO Database Connection

7. Problem opening ADO connection to database on a CDROM

8. When to open ADO Database Connection

9. Opening a connection with ADO to a MS Access 97 .mdb file

10. Access on a MS-Access-database with an ADO-Object in Jscript

11. Populating multiple dropdown from an ADO database connection

12. ADO Connections/Database Access.

 

 
Powered by phpBB® Forum Software