主题:sqlCommand的异常问题
要往表User中Insert一行(表中有两列:UserID和Password)
代码如下:
string strUserID,strPassword,strInsert;
strUserID=txtUserID.Text;
strPassword=txtPassword.Text;
strInsert="insert User (UserID,Password) value('"+strUserID+"','"+strPassword+"')";
SqlCommand comInsert=new SqlCommand(strInsert,registerConn);
registerConn.Open();
int i=comInsert.ExecuteNonQuery();
registerConn.Close();
if(i>0)
{
MessageBox.Show("已成功注册");
}
可是,提示说:
未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。
其他信息: 系统错误。
这是怎么回事阿?
代码如下:
string strUserID,strPassword,strInsert;
strUserID=txtUserID.Text;
strPassword=txtPassword.Text;
strInsert="insert User (UserID,Password) value('"+strUserID+"','"+strPassword+"')";
SqlCommand comInsert=new SqlCommand(strInsert,registerConn);
registerConn.Open();
int i=comInsert.ExecuteNonQuery();
registerConn.Close();
if(i>0)
{
MessageBox.Show("已成功注册");
}
可是,提示说:
未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。
其他信息: 系统错误。
这是怎么回事阿?