Need help connecting to Access DB

S

skyraider

Guest
Hey,

First of all, I know absolutely nothing about connecting Access databases. However, I know a tad bit of VB.NET (my site is written in ASP, though). I need some help connecting to the DB. Here's the script I'm currently using (I removed the database, account name and site name for security):

Code:
<%@ Language=VBScript %>
<% OPTION EXPLICIT %>
<%
Dim oConn

on error resume next
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:\hshome\accountname\removed\removed.mdb"
If Err.Number <> 0 Then
%>
<html>
<head>
<title>Error</title>
<!-- #INCLUDE VIRTUAL="includes/style.css" -->
</head>
<body background="images/bg3.jpg" bgcolor="#000000" text="#C0C0C0">

<p align="center"><br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br><font class="x" color="#FF0000"><b>Error accessing Database.</font><br>&nbsp;<br><font class="l" color="#FF0000">It may be being updated.<br>&nbsp;<br>Please retry in a few minutes.</b></font></p>
</body>
</html>
<%
	Response.CacheControl = "no-cache"
	Response.AddHeader "Pragma", "no-cache"
	Response.Expires = -1
	on error goto 0
	Response.Flush
	Response.End
end if
on error goto 0
%>

removed.mdb is in that directory. However, I'm getting the error message specified by the script. What exactly do I need to do to make this connection work? Please provide the exact code, as I don't know what I'm doing with Access connections.

Thanks 8)
 
skyraider said:
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:\hshome\accountname\removed\removed.mdb"


Why are you using the &?
Just use:
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\hshome\accountname\removed\removed.mdb;"
 
almost same type of problem as skyrider but asp with javascript

problems with cat.ActiveConnection = MM_tryout_STRING; coming back as
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x424c Thread 0x502c DBC 0x1536b024 Jet'.



Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
var MM_tryout_STRING = "Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\hshome\accountname\database\site2.mdb"
%>

<%
var cat = Server.CreateObject("ADODB.Recordset");
cat.ActiveConnection = MM_tryout_STRING;    
cat.Source = "SELECT * FROM cat";
cat.CursorType = 0;
cat.CursorLocation = 2;
cat.LockType = 1;
cat.Open();
var cat_numRows = 0;
%>

i have tried
"DSN=accountname_xxxx" and get general 80004005 errors

other errors trying different combinations of paths/strings
[Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.

folder / database file have full access to all from ftp app.

the same file will work locally using iis and local dsn or using same type of custom string above.
 
Try changing the driver:

var MM_tryout_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\hshome\accountname\database\site2.mdb;"
 
same deal. wonder if being on the 7 day trial has anything to do with it.

Microsoft JET Database Engine error '80004005'

Not a valid file name.

problem string = cat.ActiveConnection = MM_tryout_STRING;
 
No, trial doesn't have anything to do with it, but a number of items do. One is of course proper paths, another is that if the available quota is in use, it won't work. You would be best to send a ticket with the domain and we can check it out.
 
thx a much through trouble ticket.

2 problems.
path problem. easy fix.

dreamweaver will need to work out what is going on with it.

using "dynamic ASP / javascript" as new file option. and then filling out database and recordsets etc... with the wizards. the wizards themselves are not setting var for needed variables for the database code. X(

switching over to "dynamic ASP / VBscript" the wizards do create the needed dim's in this case for the database code to work.
 
Back
Top