Saturday, 15 February 2014

How to delete multiple rows in datagridview and database using vb.net window forms -


I've loaded with a data gridview which these codes:

  mycom.Connection = Cn Mycom.CommandText = & lt; SQL & gt; Select 'Username, Activity, CDate as `tbl_activity & date from date'; / SQL & gt; .Value dim myadap New MySqlDataAdapter (Mycom) dim mydt as grdActivity.DataSource = mydt myadap.Dispose (myadap.Fill (mydt) as the new DataTable grdActivity.Columns.Add (colCB))  

I have my delete button with these codes:

  grdActivity so dim selected = grdActivity.SelectedRows.Count selected as integer. Selected. Account & gt; 0 then you can add a confirmation message, and the user as an integer = Selected myr.Close to 0 () mycom.Connection = cn mycom.CommandText = Delete "tbl_activity where id delete it from = to Confirms, '& amp; A & amp; " '" Mycom.ExecuteReader () myr.Close () Next Else MessageBox.Show ( "1 Select the first row you delete hit in") end if  

anyone right can anyone help me with the code so I can remove not only database bound lines in your Detagrid scene I, but .. Thank directly from databases ..

"post-text" itemprop = "text" >

Do not settle the data adapter, you can use it to update the database.

  myadapt.Update (mydt)  
<: you configure the myadap with appropriate insert, update and delete commands by clicking code error handling on your button nothing much happens p> Do not read the data from the grid, let the grid force the data and the data adapter should handle the rest. I have a complete example (for MS SQL Server)


No comments:

Post a Comment