|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
datagridHi guys
I want to e able to delete rows from a datagrid and the same rows must be deleted from the datasource of the datagrid. I have a buon that removes a row based on a field value that is listed in a list box. here is te code: Dim tbl As New DataTable("DATAdemo") tbl = Me.DataSet1.Tables(0) Dim a As Integer For a = 0 To ListBox1.Items.Count tbl.Rows.RemoveAt([a]) Me.OleDbDataAdapter1.Update(tbl) Me.Refresh() ListBox1.Items.Clear() Next Can somebody modify my code to accomplish my mission? Thanx BeGentle,
Your problem is that you removes the row, which means that it is removed from the table. In the update there is no information anymore to remove it from the database. For this case the delete would be used. http://msdn2.microsoft.com/en-us/library/system.data.datarow.delete.aspx I hope this helps, Cor Show quoteHide quote "beGentle-Learner" <beGentleLear***@discussions.microsoft.com> schreef in bericht news:5318DC97-93F7-46FE-805F-B1FCC3AC2167@microsoft.com... > Hi guys > > I want to e able to delete rows from a datagrid and the same rows must be > deleted from the datasource of the datagrid. I have a buon that removes a > row > based on a field value that is listed in a list box. here is te code: > Dim tbl As New DataTable("DATAdemo") > tbl = Me.DataSet1.Tables(0) > Dim a As Integer > > For a = 0 To ListBox1.Items.Count > tbl.Rows.RemoveAt([a]) > Me.OleDbDataAdapter1.Update(tbl) > Me.Refresh() > ListBox1.Items.Clear() > Next > > Can somebody modify my code to accomplish my mission? > Thanx
+ and & operators
XML DesignMode broken - suggested path? Threads do not Terminate! a simply VB.net/ SQL SERVER question Folder Access Listing change cursor to hourglass (WaitCursor) between try..catch Icons for explorer app depending on OS VB.net Express compiling problems GetPrivateProfileString problem! |
|||||||||||||||||||||||