我的代码如下:
string phone = txtphone.Text;
string username = lblmember.Text;
string a = string.Format("SELECT * FROM ContactsInfo" + " WHERE Phone='{0}'", phone);
int count = (int)DB.GetScala(a);
if (count > 0)
{
if (MessageBox.Show("您是否要删除用户:" + username, "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
string sql = string.Format("DELETE FROM ContactsInfo" + " WHERE Name='{0}' AND Phone='{1}'", username, phone);
int result = DB.ExecuteSQL(sql);
if (result > 0)
{
MessageBox.Show("已删除!");
}
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("删除失败!");
}
}
else {
MessageBox.Show("电话号码不存在!");
}
提示有报错的是这一行:
int count = (int)DB.GetScala(a);
提示的错误是:
“未将对象引用设置到对象的实例。”
应该怎么解决一下呢