Problems With Delete query in SQLCE

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
 
M

Milsnips

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top