Forum Moderators: open

Message Too Old, No Replies

Connection string to remote host using ms access.mdb

         

latoc

8:59 pm on Mar 25, 2010 (gmt 0)

10+ Year Member



I am using an ms access database for my gueatbook.aspx page. It works on my localhost, located on F:\ but not when uploaded to my remote host server. Failure; connection string for the access.mdb. My connection string for the localhost is:

[size=2]Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("Attend.mdb") & ";"[/size]


According to my remote host server the path to my webspace is \\PDC1\sites\f\Example.com\public_html I have tried many ways adding this to my connection string without success.

Additional info. Web.config file:

[size=2]<add name="AttendConnectionString3" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\attend\Attend.mdb"
providerName="System.Data.OleDb" />[/size]

help would be appreciated

latoc

[edited by: Ocean10000 at 9:56 pm (utc) on Mar 25, 2010]
[edit reason] Examplfied Hostname [/edit]

Ocean10000

9:54 pm on Mar 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If "f" drive is a mapped drive, it will not work in IIS.

IIS by default uses "Network Service" account for most websites, (this may vary based on IIS version and if it configured differently by the hosting provider). This account will not have the same drive mappings as your login account. And if I remember correctly it will not have permissions to access network shares.

If you are running Asp.Net 2.x you can put the DB file in the App_Data Folder, which is protected from being able to be downloaded from by Asp.Net.

Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("/App_Data/Attend.mdb") & ";"

latoc

10:39 pm on Mar 25, 2010 (gmt 0)

10+ Year Member



Thank you for prompt response. I have tried the suggested connection string including the webspace \\PDC1\sites\f\Example.com\public_html but still have an error 'Could no find file \\PDC1\sites\f\Example.com\public_html\App_Data\Attend.mdb'

latoc

[edited by: Ocean10000 at 4:30 am (utc) on Mar 26, 2010]
[edit reason] Examplified [/edit]

LifeinAsia

11:06 pm on Mar 25, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Did you upload Attend.mdb to the App_Data folder?

latoc

11:52 pm on Mar 25, 2010 (gmt 0)

10+ Year Member



Sorry you’re right I did not upload Attend.mdb to the App_Data folder.
Using connection string;
Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("/App_Data/Attend.mdb") & ";" Returns error ‘F:\attend\Attend.mdb is not a valid path'. The is the website path on my local machine.

The only reference to this path is in the web.config file ‘<add name="AttendConnectionString3" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\attend\Attend.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
Is this the problem?

LifeinAsia

12:00 am on Mar 26, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I would guess so.

Since your local server and hosting server have different directory structures, you will have to account for it in your coding. Otherwise, the same code will not work in both places.

One suggestion would be to add an App_Data folder to your local server and put the DB file in there.

latoc

12:09 am on Mar 26, 2010 (gmt 0)

10+ Year Member



Thank you for your suggestion. I will try that and report.
latoc