各位C#里面app.config连接数据库的字符串怎么写
1个回答
展开全部
在app.config里面写上下面的代码:
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="StudentSystem.Properties.Settings.SchoolConnectionString"
connectionString="Data Source=PC-200908251645;Initial Catalog=School;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
然后访问时写上:
SqlConnection con =
new SqlConnection("server=PC-200908251645;database=school;Integrated Security=True")
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="StudentSystem.Properties.Settings.SchoolConnectionString"
connectionString="Data Source=PC-200908251645;Initial Catalog=School;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
然后访问时写上:
SqlConnection con =
new SqlConnection("server=PC-200908251645;database=school;Integrated Security=True")
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询