我在app.config中设置了sql server的路径,我想在表中插入数据?
答案 0 :(得分:0)
using (SqlConnection Conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["YourConfigFileAssignName"].ConnectionString))
{
};
YourConfigFileAssignName
是app.config
文件中指定的酸连接字符串名称。
<connectionStrings>
<add name="YourConfigFileAssignName"
connectionString="Data Source=YourDataSource;Initial Catalog=YourDBname;User ID=SQLid;Password=SQLpass"
providerName="System.Data.SqlClient"/>
</connectionStrings>