| |

VerySource

 Forgot password?
 Register
Search
Author: zephyr1982

web.config database connection error

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-15 13:45:01
| Show all posts
<configuration>
   <appSettings>
        <add key="msn" value="server=127.0.0.1;uid=sa;pwd=sa;database=BookShop" />
   </appSettings>
</configuration>

string strConString = ConfigurationSettings.AppSettings[ "msn" ];

Maybe this line, you try it!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-15 18:00:01
| Show all posts
<appSettings>
    <add key="connstr" value="server=.;uid=zbr;pwd=#szzemucompany#;database=dbok" />
</appSettings>

--------------------
public static string ConnStr=System.Configuration.ConfigurationSettings.AppSettings["ConnStr"];


If it doesn't work again, it's not a problem in this regard.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-16 18:00:01
| Show all posts
using System.Configuration;
public static int ExecuteSql(string strSql)
        {
SqlConnection myconn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnStr"]);
SqlCommand mycomm = new SqlCommand(strSql, myconn);


Try
Reply

Use magic Report

1

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-24 20:30:01
| Show all posts
It turned out that\in the instance name of SQLSERVER, ZEMU-A12\COMPANY, was escaped, and I changed it in web.config


    <add key="strConnString" value="Server=ZEMU-A12$COMPANY;UID=zbr;PWD=#szzemucompany#;Database=dbok"></add>


It is correct to replace $ with\\when reading, thank you brothers upstairs!
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