谁能帮助我为什么会收到此错误?提前致谢..
当 IDENTITY_INSERT 设置为 OFF 时,无法在表“OS_Mailinglist1”中插入标识列的显式值。说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:
System.Data.SqlClient.SqlException:当 IDENTITY_INSERT 设置为 OFF 时,无法在表“OS_Mailinglist1”中插入标识列的显式值。源错误:
第 312 行:cmd.ExecuteNonQuery();
第 313 行:ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Registered your Email ID and Area of interest.');", true);
显示错误的页面后面的代码:
else
{
Util.SetConnection();
Util.sql_con.Open();
cmd = new SqlCommand("insert into offsale.OS_Mailinglist1(UserName,Area_Of_Interest,Mail_Pwd)values('" + txtEmail.Text.ToString() + "' ,'" + arrvalues + "','" + ViewState["pwd"].ToString () + "')", Util.sql_con);
// cmd = new SqlCommand("insert into offsale.OS_Mailinglist1(UserName,Area_of_interest,Mail_Pwd)values('" + txtEmail.Text.ToString() + "' ,'" + arrvalues + "','" + passwrd.Text.ToString () + "')", Util.sql_con);
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successsfully Registered your Email ID and Area of interest.');", true);
Util.sql_con.Close();