Andrei On

Andrei On

  • NA
  • 1
  • 1.3k

Delete problem when the table form database is almost empty

Jul 22 2013 7:15 AM

I can't delete a field from a database (using query) when the database is empty and it contains just the field that I want to delete.

con.Connection = con;
con.Open();

com.CommandText = "DELETE FROM tabel1 WHERE b3='" + textBox1.Text + "';";
com.ExecuteNonQuery();

com.CommandText = "SELECT b3 FROM tabel1";
com.ExecuteNonQuery();

dr = com.ExecuteReader();
while (dr.Read())
{
     textBox1.Text = dr.GetValue(0).ToString();
}
con.Close();

The idea is that after the code is executed, textBox1 has the same value (dose not receive the null value resulted from deletion)

Help!


Answers (1)