数据库有记录但是,提示错误 存储数据错误正在中止线程。
protected void Button1_Click(object sender, EventArgs e)
{
try
{ string employee1 = Convert.ToString(Session["name"]);
string employee2 = HttpUtility.UrlDecode(Request.QueryString["name2"]); string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" + HttpContext.Current.Server.MapPath(@"~/minisurvey_360/#db.mdb");
OleDbConnection con = new OleDbConnection(strCon);
con.Open();
string strsql = "insert into qa1(q1,q2,q3,q4,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q17,q18,q19,q20,q21,q22,q23,q24,q25,q26,q27,employee1,employee2) values(";
strsql += "'" + RadioButtonList1.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList2.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList3.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList4.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList5.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList6.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList7.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList8.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList9.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList10.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList11.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList12.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList13.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList14.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList15.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList16.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList17.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList18.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList19.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList20.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList21.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList22.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList23.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList24.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList25.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList26.SelectedItem.Text.ToString() + "'";
strsql += ",'" + RadioButtonList27.SelectedItem.Text.ToString() + "'";
strsql += ",'" + employee1 + "'";
strsql += ",'" + employee2 + "')";
OleDbCommand cmd = new OleDbCommand(strsql, con);
cmd.ExecuteNonQuery();
cmd.Dispose();
con.Close();
Response.Redirect("Default.aspx");
}
catch (Exception ex)
{ throw new Exception("存储数据错误" + ex.Message);
}
}
}
检查Response.Redirect("Default.aspx");