请教各位:
如何在listview中通过选择多项来删除数据库中的信息。
我现在的程序如下:
string strConnect = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " +
Application.StartupPath + "\\MY.MDB";
OleDbConnection conConnection = new OleDbConnection(strConnect);
conConnection.Open();
ListViewItem newItem;
newItem = this.listView1.SelectedItems[0]; string strCommand = string.Format("delete from Persons where id = {0}", int.Parse(newItem.SubItems[0].Text));
//MessageBox.Show(strCommand );
OleDbCommand cmd = new OleDbCommand(strCommand, conConnection);
cmd.ExecuteNonQuery();
conConnection.Close();
如何在listview中通过选择多项来删除数据库中的信息。
我现在的程序如下:
string strConnect = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " +
Application.StartupPath + "\\MY.MDB";
OleDbConnection conConnection = new OleDbConnection(strConnect);
conConnection.Open();
ListViewItem newItem;
newItem = this.listView1.SelectedItems[0]; string strCommand = string.Format("delete from Persons where id = {0}", int.Parse(newItem.SubItems[0].Text));
//MessageBox.Show(strCommand );
OleDbCommand cmd = new OleDbCommand(strCommand, conConnection);
cmd.ExecuteNonQuery();
conConnection.Close();
{
newItem = this.listView1.SelectedItems[i]; string strCommand = string.Format("delete from Persons where id = {0}", int.Parse(newItem.SubItems[0].Text));
//MessageBox.Show(strCommand );
OleDbCommand cmd = new OleDbCommand(strCommand, conConnection);
cmd.ExecuteNonQuery();
}
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html