Re: Cannot Open Access File



re:
!> 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.

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

c:\somepath\someother dir\Acc.mdb

or... a virtual path which can be translated by Server.MapPath.

DBConnection = New OledbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Server.Mappath "/App_Data/Acc.mdb")

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.

Placing it in the root directory of your app allows hackers to download your database.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Mark Rae [MVP]" <mark@xxxxxxxxxxxxxxxxx> wrote in message news:eVUGl6ywHHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
"dancer" <dancer@xxxxxxxxxxxxx> wrote in message news:%2377Q0uywHHA.3400@xxxxxxxxxxxxxxxxxxxxxxx

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


.