string str = "";
string[] ckb = null;
str = Request.Form.Get("Checkbox1");
ckb = str.Split(new char[] { ',' });
for (int i = 0; i < ckb.Length; i++)
{
string strsql = "delete from Users where UserID='" + ckb[i] + "'";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLConnectionString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand(strsql, con);
SqlTransaction Trans = con.BeginTransaction();
try
{
com.Transaction = Trans;
com.ExecuteNonQuery();
Trans.Commit();
}
catch(Exception ex)
{
Trans.Rollback();
Response.Write(ex.Message);
}
Response.Write("<script language='javascript'>alert('数据已被保存!');</script>");
BindUserData();
我的一段代码如上,调试时出现一个错误:ckb = str.Split(new char[] { ',' }); 未将对象引用为实例.
请各位大侠指点一下