1
Answer

Delete problem when the table form database is almost empty

Andrei On

Andrei On

11y
1k
1

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)