Locating Database

  • Thread starter Thread starter J. Babe
  • Start date Start date
J

J. Babe

I've built an ASP.NET application. I have built a .DLL (VB.NET
classes) that handles the database transactions. The web page then
gets data via the VB.NET DLL.
I am having trouble with the location of the database, I was setting
the location to "C:\myDB.mdb" for testing purposes. I imported
System.Web into my VB DLL and used:
HttpContext.Current.Server.MapPath(".\bin\myDB.mdb")
to set the location of the database to the bin folder of my .ASPX
project. However, when I go to update the database I get the
exception:

'Operation must use an updateable query.'

How can I dynamically (programmatically) set the database location?
 
How about putting that information in the Web.Config file.

<appSettings>
<add key="dbLocation" value = "~\data\myDB.mdb" />
</appSettings>


vb.NET: get value from web.config

Dim dbLocation As String = context.Server.MapPath( CStr (
System.Configuration.ConfigurationSettings.AppSettings( "dbLocation")))


HTH
 
Back
Top