年末总结7
这是我在做ASSET工程时,DBHelper.cs不管用了,也就是数据库连不上了。
问题出在初始化数据库错误,导致下方的sql语句不能执行,得出的result值为null
public static int ExecuteSql(string sql)
{
cn.Open();
SqlCommand cmd = new SqlCommand(sql,cn);
int result = cmd.ExecuteNonQuery();
cn.Close();
return result;
}
解决方法:回头看看数据库连接语句
Data Source = localhost;Integrated Security = SSPI;Initial Catalog = Module_4_DB;//分号隔开
以上。