1
Reply

Delete Record from Combox

Raam Kumar

Raam Kumar

May 21 2008 11:25 PM
3k

Hi,

I am really new to C# and access. I have a access database. I have connected it through dataadapter and databinding.

I get the data from the database to the combo. When ever I select an item I get the value for the corresponding item from the database and shown in a text box.

Now I would like to delete a record that is selected in the combo box. I have a delete button.

Here is the below which I tried:

I hve initalized the database connection and database already.

private void recorddeleteButton_Click(object sender, EventArgs e)
{

string delStr = "Delete FROM [Test] Where fn = '" + combobox1.Text + "'";
dAdapter =
new OleDbDataAdapter(delStr, myConn);
dset =
new DataSet();
dAdapter.TableMappings.Add(
"Table", "Test");
dAdapter.Fill(dset);
this.dviewmanager = dset.DefaultViewManager;
this.combobox1.DataSource = this.dviewmanager;
this.combobox1.DataBindings.clear();
this.combobox1.DisplayMember = "Test.fn";
}

but this doesn't do anything. I would like delete the selected Item and then update the combox box with the remaining records.

How do I go about doing it?

Awaiting your response!
Thanks!


Answers (1)
Next Recommended Forum