Database connection using Server.MapPath

spyarena

New Member
I can get my ASP.NET database connection to work when I use the full physical path to the database, but I want to use Server.MapPath (or equivalent), as I do on my ASP pages. What is the correct connection string? (Using an Access database) Thanks for any help!New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbYour_DB.mdb"))I use the Request.PhysicalApplicationPath function to get the current path. Here is a sample Access ConnectionString<BR><BR>MyConnection = New OleDBConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Request.PhysicalApplicationPath & "databasemydb.mdb;")Didn't know about Request.PhysicalApplicationPath - works particularly well for my circumstances. Thanks for the help.
 
Back
Top