我试图在将记录写入文件之前查看表中是否存在记录,但我一直收到错误
string InformationCheck = "Select FName,LName from Customer where FName ='" + this.f_Name.Text + "' and LName = '" + l_Name.Text + "'";
OleDbCommand InfoCheck = new OleDbCommand(InformationCheck, conn);
String strResult = String.Empty;
try
{
conn.Open();
strResult = (String)InfoCheck.ExecuteScalar();
if (strResult.Length == 0)
{
MessageBox.Show("Dose Not Exist");
AddInfo.ExecuteReader();
conn.Close();
this.Hide();
f1.Show();
}
else
{
MessageBox.Show("Exists");
}
}
catch (Exception ex)
{
MessageBox.Show("" + ex + "");
}