Cannot Open Access File

M

Mark Rae [MVP]

!> DBConnection = New
OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=Acc.mdb"

That connection assumes the mdb file is located in the
c:\windows\system32\inetsrv directory.
Indeed.

An OledbConnection expects a complete physical directory path,
if the path is ,ocated outside the website's directory path :

Quite so.
Btw, Acc.mdb should *never* be placed anywhere but in the App_Data
directory.
As long as the mdb is in the App_Data dir, it cannot be downloaded via a
direct link.

Definitely.
 
J

Juan T. Llibre

See my just-sent reply to this thread.

It has the info you need to solve your problem.





Where *precisely* on your webserver is the Acc.mdb Jet database? Is it in your web app's virtual directory, maybe in the
App_Data subfolder...?

I tried it in the same place as my aspx file (the root)
I also tried it in the database folder.


"dancer said:
> I did NOT install Microsoft Access.

That's good.
> The reason I went to my host server TO install it is because YOU asked,
> "Have you actually installed a copy of Microsoft Access on your webserver? Yes or no?"
> when I mentioned the error, "Could not find file 'c:\windows\system32\inetsrv\Acc.mdb'"
> Do you remember that?

Yes I do.
> Why did you ask me that?

Because I wanted to make certain that you *hadn't* installed Microsoft Access on your webserver... :)
> What is your reason as to why I get the above error when trying to run my
> file at my host server? Why is it looking for the file on my computer? I
> downloaded the acc.mdb file to the host. Nowhere in my code do I refer to
> "c:\windows, etc."

Because it can't find the Jet database, so it's looking in the folder it's currently running from instead...
> DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=Acc.mdb"

Where *precisely* on your webserver is the Acc.mdb Jet database? Is it in your web app's virtual directory, maybe in
the App_Data subfolder...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
 
D

dancer

Juan,
I tried the path, which did not work.
I tried the physical path, but it is still looking on my c drive instead of
the server.
Here is the error message and the code follows. Can you tell my what is my
problem?

'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException:
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.

Source Error:

Line 6: Dim DBConnection As OledbConnection
Line 7: DBConnection = New
OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")
Line 8: DBConnection.Open()
Line 9:
Line 10: Dim DBCommand As OledbCommand

Source File: e:\accounts\whee13\WWW\database_acc_host.aspx Line: 8

Stack Trace:

[OleDbException (0x80004005):
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a valid
path. Make sure that the path name is spelled correctly and that you are
connected to the server on which the file resides.]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvider() +57
System.Data.OleDb.OleDbConnection.Open() +203
ASP.database_Acc_host_aspx.Page_Load(Object sender, EventArgs e) in
e:\accounts\whee13\WWW\database_acc_host.aspx:8
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750



<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data.Oledb" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)


Dim DBConnection As OledbConnection

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")

DBConnection.Open()

Dim DBCommand As OledbCommand

DBCommand = New OledbCommand("SELECT * FROM table1, Acc")

Dim SQLString AS String



SQLString = "SELECT * FROM Table1"

DBCommand = New OleDBCommand(SQLString, DBConnection)

Dim DBReader AS OledbDatareader

DBReader = DBCommand.ExecuteReader()


MyDataGrid.DataSource = DBReader

MyDataGrid.DataBind()

DBReader.Close()

DBConnection.Close()

End Sub

</script>

</head>

<body>

<form id="form1" runat="server">

<asp:DataGrid id="MyDataGrid" runat="server"/>

</form>

</body>

</html>
 
J

Juan T. Llibre

re:
!> OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=www.wheelers.com\fpbd\Acc.mdb")

That is not a valid physical path.
What you need to use is Data Source=drive:\somepath\fpbd\Acc.mdb

That will depend on the path to Acc.mdb *on the www.wheelers.com server*.







dancer said:
Juan,
I tried the path, which did not work.
I tried the physical path, but it is still looking on my c drive instead of the server.
Here is the error message and the code follows. Can you tell my what is my problem?
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a valid path. Make sure that the path name is
spelled correctly and that you are connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack
trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: 'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is
not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which
the file resides.

Source Error:

Line 6: Dim DBConnection As OledbConnection
Line 7: DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")
Line 8: DBConnection.Open()
Line 9:
Line 10: Dim DBCommand As OledbCommand

Source File: e:\accounts\whee13\WWW\database_acc_host.aspx Line: 8

Stack Trace:

[OleDbException (0x80004005): 'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a valid path. Make
sure that the path name is spelled correctly and that you are connected to the server on which the file resides.]
 
M

Mark Rae [MVP]


This is never going to work. See Juan's previous reply - the Data Source
element of the connection string needs to point at a physical file, not a
URL, so:

1) If your web application doesn't already contain an App_Data folder,
create one

2) Place your Acc.mdb database in the App_Data folder

3) Make sure that the account that your web app is running under has write
permissions on the App_Data folder

4) Change your connection string to:
DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=" & Server.Mappath("~\App_Data\Acc.mdb") & ";"
 
D

dancer

How can I know which drive it is on?



Juan T. Llibre said:
re:
!> OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")

That is not a valid physical path.
What you need to use is Data Source=drive:\somepath\fpbd\Acc.mdb

That will depend on the path to Acc.mdb *on the www.wheelers.com server*.







dancer said:
Juan,
I tried the path, which did not work.
I tried the physical path, but it is still looking on my c drive instead
of the server.
Here is the error message and the code follows. Can you tell my what is
my problem?
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException:
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.

Source Error:

Line 6: Dim DBConnection As OledbConnection
Line 7: DBConnection = New
OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")
Line 8: DBConnection.Open()
Line 9:
Line 10: Dim DBCommand As OledbCommand

Source File: e:\accounts\whee13\WWW\database_acc_host.aspx Line: 8

Stack Trace:

[OleDbException (0x80004005):
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.]
 
M

Mark Rae [MVP]

Dancer,
How do I *Make sure that the account that your web app is running under
has write permissions on the App_Data folder*?

With the greatest of respect, this question has already been answered at
least once already in this thread...

If you are an administrator of the webserver, open up Windows Explorer,
navigate to the folder, right-click on it, click Properties, Security and
give the account that your web app is using write access to the folder.

If this is a remote site e.g. at a 3rd-party ISP, then you will need to
contact them and tell them you need write access to your virtual directory's
App_Data folder...
 
D

dancer

WITH THE GREATEST OF RESPECT, we have been talking just now about a host
server - which to me is a remote site, and never have "write permissions"
been addressed about a remote site.
 
M

Mark Rae [MVP]

WITH THE GREATEST OF RESPECT, we have been talking just now about a host
server - which to me is a remote site, and never have "write permissions"
been addressed about a remote site.

Sigh... so does your account with your ISP give you have write permissions
on your virtual directory or not...?

You will need to have write permissions on the folder which contains the Jet
database...
 
D

dancer

YEA!!!!!!!!!!
IT WORKED!!!!!!
THANK YOU!!!!!!
Patience, persistence and perspiration make an unbeatable combination for
success.
- Napolean Hill





Juan T. Llibre said:
re:
!> OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")

That is not a valid physical path.
What you need to use is Data Source=drive:\somepath\fpbd\Acc.mdb

That will depend on the path to Acc.mdb *on the www.wheelers.com server*.







dancer said:
Juan,
I tried the path, which did not work.
I tried the physical path, but it is still looking on my c drive instead
of the server.
Here is the error message and the code follows. Can you tell my what is
my problem?
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException:
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.

Source Error:

Line 6: Dim DBConnection As OledbConnection
Line 7: DBConnection = New
OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=www.wheelers.com\fpbd\Acc.mdb")
Line 8: DBConnection.Open()
Line 9:
Line 10: Dim DBCommand As OledbCommand

Source File: e:\accounts\whee13\WWW\database_acc_host.aspx Line: 8

Stack Trace:

[OleDbException (0x80004005):
'c:\windows\system32\inetsrv\www.wheelers.com\fpbd\Acc.mdb' is not a
valid path. Make sure that the path name is spelled correctly and that
you are connected to the server on which the file resides.]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top