Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2004, 04:10 PM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to dave3134
Default problem using asp with database created with vba

Can someone please tell me why the following generates an error.


<% Option Explicit %>
<html>
<head>
    <title>New Page</title>
</head>

<body>

<%
'************************************************* ***********************
' The DataStore file
'
'************************************************* ***********************

dim accessDB
dim strSource,oConn,oRS

'Find the full path of the database
accessDB=Server.MapPath("G:\Tafe\database_programm ing\vba\vba_assignment\vba_assignment.mdb")
'Use Microsoft Jet v4.0
strSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="strSource=strSource & accessDB & ";"

           '*** set the connection object
           set oConn=Server.CreateObject("ADODB.Connection")

           '*** make the ConnectionString property the strSource from the DataStore file
           'oConn.ConnectionString=strSource

           '*** open the connection
           'oConn.Open

           oConn.Open strSource
           set oRS = Server.CreateObject("ADODB.Recordset")
           oRS.Open "tblCompanyDetails",oConn

           do while not oRS.EOF
                 Response.Write(oRS("strCoName")) & "<br>" &
                   vbCrLf)
              oRS.MoveNext
           loop
%>



</body>
</html>

I've tried using slashes both ways for the .MapPath command. The error seems to be at srcSource = ... and it is called error 8. The idea was to display all strCoName stored in tblCompany details which is a table in a database stored in vba_assignment.mdb.

If it wasn't for the problem connecting to the database, would my code
display this info (assuming the correct name is used for the table etc)?

Dave
 
Old June 8th, 2004, 08:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

This line looks incorrect.
strSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="strSource=strSource & accessDB & ";"
Should it be?
strSource = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & accessDB & ";"




======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically created control's values to database saket123 ASP.NET 2.0 Basics 4 August 13th, 2008 12:49 AM
Deletion of a created database in sql server pramos.21d SQL Server 2000 0 March 2nd, 2005 09:29 AM
Access VBA problem with Oracle database pankaj_daga Oracle 0 September 7th, 2004 08:47 AM
Excel Workbook created from Access VBA clueless_may Access VBA 0 June 8th, 2004 09:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.