问题描述:
问题如题目(asp.net)
求,急,谢了
问题解答:
DB类里写如下
public static string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["你的数据库名"].ToString();
在写一个添加方法
public static int GetExcuteNonQuery(string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand(SQLString, connection))
{
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch (System.Data.SqlClient.SqlException e)
{
connection.Close();
throw e;
}
finally
{
cmd.Dispose();
connection.Close();
}
}
}
}
然后在你需要添加的逻辑类中调用OK了