Tips: Read Access Database with Physical Path

zhaozj2021-02-16  92

Private

Static

String

CONSTRING;

/ ** /

///

/// data connection string ///

public

Static

String

ConnectString

{Get {if (Constring == null) {Constring = string.Format (System.Configuration.ConfigurationSettings.AppSettings [ "ConnectString"], System.Web.HttpContext.Current.Request.PhysicalApplicationPath (System.Configuration.ConfigurationSettings.AppSettings [ "Dbpath"])); return;}}}

See globals.cs

<

Appsettings

>

<

Add

Key

= "ConnectString"

Value

= "Data Source = {0}; password =; provider = microsoft.jet.oledb.4.0"

/>

Data driver

->

<

Add

Key

= "Dbpath"

Value

= "DatabaseHover.mdb"

/>

Physical path

->

Appsettings

>

See Web.config

Always a physical path when calling connectstring

D: /hover/hover.web/database/hover.mdb

HttpRequest.PhysicalApplicationPath properties

Get the physical file system path of the root directory currently being executed

转载请注明原文地址:https://www.9cbs.com/read-13600.html

New Post(0)