Problems With Delete query in SQLCE

  • Thread starter Thread starter Wrecked
  • Start date Start date
W

Wrecked

hello,
Bellow is the code which i am using to delete a record.

SqlCeConnection conn = null;
conn = new SqlCeConnection("some location");
conn.Open();
SqlCeCommand cmd = new SqlCeCommand();
cmd.Connection = conn;
cmd.CommandText = "DELETE FROM
RegBillers_DBRecordType WHERE billId='" +
listBox1.SelectedItem.ToString() + "'";
cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Close();

The table name is RegBillers_DBRecordType and i am trying to delete the
record where the field billId is equal to the one accepted from the
user using the list box.

However when i read the whole table again, i find that the record is
not delete.

Can someone pointout where am i going wrong???

Thanks and Regards
Rithesh

Student
MTech, IIIT, Bangalore
 
Hi there,

try replacing listBox1.SelectedItem.ToString() ..with
listBox1.SelectedValue.

also do a MessageBox.show(cmd.CommandText) just before you execute the
procedure to see that the value you want is being passed in the query.

regards,
Paul
 
Back
Top