Home > Net >  To do a listview by id deletion of data but didn't delete page deleted database bosses help see
To do a listview by id deletion of data but didn't delete page deleted database bosses help see

Time:09-21

Private void button1_Click_1 (object sender, EventArgs e)
{
/* this Controls,
String constr.=CommonUtils GetDbConnectionString ();
SqlConnection con=new SqlConnection (constr);
This. Cursor=your Cursors. WaitCursor;
con.Open();
SQL=con SqlCommand. CreateCommand ();
Sql.Com mandText="delete from logon the where";
SqlDataReader dar=SQL. ExecuteReader ();
Con. The Close (); */
If (this. ListView1. SelectedItems. Count==0)
{
MessageBox. Show (" please choose to delete rows of data ", "Error", MessageBoxButtons. OK, MessageBoxIcon. Error);
}
The else
{
String constr.=CommonUtils GetDbConnectionString ();
SqlConnection conn1=new SqlConnection (constr);
Conn1. The Open ();
String SQL=the string. Format (" delete from logon the where id={0} ", Convert. ToInt32 (listView1. SelectedItems [0]. Text. The ToString ()));
SqlCommand command=new SqlCommand (SQL, conn1);
Int a=command. ExecuteNonQuery ();
This. The listView1. SelectedItems [0]. Remove ();
}
}
  • Related