Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

aspx pages trying to connect to Access MDB Database

HI

Im trying to connect to an access MDB using an aspx page and VB.NET

The application works on my local machine but it wont work once I upload to the webserver

The database connection code is as follows at present

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\custsupport\database\data.mdb"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

When I upload to the webserver I change the connection - .....Data Source=custsupport/database/data.mdb

So this fits in with the domain layout = http://www.mydomain.co.uk/custsupport/database/data.mdb

however I keep getting errors from the server as it cant find the file in the path

Error =

'c:\windows\system32\inetsrv\custsupport\database\data.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.

Can anyone help me as I really dont know where to go from here

Regards

KevNet
0
KevNet
Asked:
KevNet
1 Solution
 
TimCotteeCommented:
Hi KevNet,

Use:

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" & Server.MapPath("custsupport/database/data.mdb")

This will get the "Real" file location relative to the webserver from the path you have specified.

Tim Cottee
0
 
KevNetAuthor Commented:
Cool - thanks for the help all working now!

Something I will def not forget how to do!
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now