在<system.web>前写
<appSettings>
<add key="SQLConnectionString" value="Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=dianxinkapin;Data Source=new"/>
</appSettings>
然后在程序中写:
string constr=System.Configuration.ConfigurationSettings.AppSettings["SQLConnectionString"];
说明:
Password是数据库密码;
User ID是数据库用户名;
nitial Catalog是数据库名称;
Data Source是数据源IP或计算机名称