| |

VerySource

 Forgot password?
 Register
Search
View: 809|Reply: 3

How to write the access database as a relative path in the cs file of the web application

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-23 14:00:02
| Show all posts |Read mode
How to write the access database as a relative path in the cs file of the web application

The database is placed in the app_Data folder of the project, but ~ / app_Data / xxx.mdb does not recognize it, you must write the absolute path
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-7 13:00:01
| Show all posts
An officially released project does not work with absolute paths. Generally, server.MapPath ("app_Data / xxx.mdb") is used to convert the path. Pay attention to the relationship between the file location of this statement and the directory in ()
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-2 13:45:01
| Show all posts
Add on the <appSettings> node under Web.Config
<add key="AccessConnection" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Database name.mdb"/>
Read in the program
private static readonly string connectionString=ConfigurationSettings.AppSettings["AccessConnection"].ToString();
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-9-2 14:00:02
| Show all posts
string connStr = "Provider=Microsoft.Jet.OleDb.4.0;data source=" + Server.MapPath("~/App_Data//TreeViewDemo.mdb");
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list