用户代码未处理 System.NullReferenceExceptionMessage="未将对象引用设置到对象的实例。"
private bool checkname(string username, string idcard)
{
bool bl = false;
SqlConnection sqlconnection = new SqlConnection(Program.GetConnectionString());
SqlCommand dbcommand = new SqlCommand();
dbcommand.Connection = sqlconnection;
dbcommand.CommandType = System.Data.CommandType.Text;
dbcommand.CommandText = "select userid from resume where name='" + username + "'and idcard='" + idcard + "';";
dbcommand.Connection.Open();
int n = (int)dbcommand.ExecuteScalar();
if (n > 0)
{
userid = n;
bl = true;
}
dbcommand.Connection.Close();
return bl;
}
用户代码未处理 System.NullReferenceException
Message="未将对象引用设置到对象的实例。"
在 System.Windows.Forms.Control.OnValidated(EventArgs e)
在 System.Windows.Forms.Control.PerformControlValidation(Boolean bulkValidation)
在 System.Windows.Forms.ContainerControl.ValidateThroughAncestor(Control ancestorControl, Boolean preventFocusChangeOnError)
错误在这一句
int n = (int)dbcommand.ExecuteScalar();