| |

VerySource

 Forgot password?
 Register
Search
View: 924|Reply: 6

How to connect asp.net to the database is C #

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-6 12:20:01
| Show all posts |Read mode
<add key = "ConnectionString" value = "Provider = Microsoft.Jet.OleDb.4.0; Data Source = MapPath (Northwind.mdb)" />

I want a relative path?
How about it?

Help out
Reply

Use magic Report

0

Threads

15

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 13:42:01
| Show all posts
<add key = "ConnectionString" value = "Provider = Microsoft.Jet.OleDb.4.0; Data Source =. / Northwind.mdb" />
./ represents the current path.
Reply

Use magic Report

0

Threads

10

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 16:51:01
| Show all posts
<appSettings>
       <add key = "con" value = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="> </ add>
       <add key = "data" value = "/ Data / mdb"> </ add>
</ appSettings>

string myCon = System.Configuration.ConfigurationSettings.AppSettings ["con"] + HttpContext.Current.Server.MapPath ("~" + System.Configuration.ConfigurationSettings.AppSettings ["data"]);
Reply

Use magic Report

0

Threads

41

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-22 01:09:01
| Show all posts
OleDbConnection con = new OleDbConnection ("Provider = Microsoft.Jet.OLEDB.4.0; Password =; User ID = Admin; Data Source =" + HttpContext.Current.Server.MapPath (@ "App_Data\service_applies.mdb") + ";") ;
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-22 15:27:01
| Show all posts
You cannot use functions or methods in web.config. You can only use absolute strings. You can set a relative path and then stitch it in the program.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-22 23:18:01
| Show all posts
mark
Reply

Use magic Report

0

Threads

20

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-1-23 02:45:01
| Show all posts
This is theklongvv.
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