开发者

Deleting An item from a List Box from a Database

Hi Im trying to delete an item from the listbox which the user selects here you can find my code and a screenshot tnx.

Code:

public void deleteEvent(ListBox list_event)
{
    int i = list_event.SelectedIndex;

    ds.Tables["tblEvents"].Rows[i].Delete();
    da.Update(ds.Tables["tblEvents"]);
}

Im getting开发者_StackOverflow Object reference not set to an instance of an object Exception.

ScreenShot:

Deleting An item from a List Box from a Database


  • Make sure ds is not null.
  • Make sure there is a table called tblEvents in the data set, ds.
  • Make sure the number of rows in the tblEvents is large enough so that the index you're using when deleting fits within the number of rows.
  • Make sure that the data adapter da is not null.

Without any further information, it's close to impossible to give any more insights.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜