I need to check if a record is saved into database or not. If it was saved in database open another form, else show a message that it is not in database.
If the record is not in database I get this error Object reference not set to an instance of an object.
This is my code please help me to find the error here:
string cmdStr = "Select NO from COM_LIST_EXPORT where NO = '" + txtNO.Text + "'";
SqlCommand cmd = new SqlCommand(cmdStr, CN);
int count = (int)cmd.ExecuteScalar();
if (count == Convert.ToInt32(txtNO.Text))
{
Archive_Sader dd = new Archive_Sader();
dd.Show();
}
else
{
MessageBox.Show("please save first");
}