I have Following code but rest of it how?
Posted
by Hakan
on Stack Overflow
See other posts from Stack Overflow
or by Hakan
Published on 2010-06-08T17:09:09Z
Indexed on
2010/06/08
17:12 UTC
Read the original article
Hit count: 309
vb.net
I have following code which is putting value of text box to table but i can't manage how to delete record. Can someone help me about it?
Dim meter As DataTable = Me.DataSet1.Tables.Item("tblmeter")
Dim row As DataRow = meter.NewRow()
row.Item("No") = Me.txtno.Text
row.Item("Turnover") = Me.txtturnover.Text
row.Item("Total Win") = Me.txttotalwin.Text
row.Item("Games Played") = Me.txtgamesplayed.Text
row.Item("Credit In") = Me.txtcreditin.Text
row.Item("Bill In") = Me.txtbillin.Text
row.Item("Hand Pay") = Me.txthandpay.Text
row.Item("Date") = DateTime.Today.ToShortDateString
meter.Rows.Add(row)
Me.TblMeterTableAdapter.Update(Me.DataSet1.tblMeter)
meter.AcceptChanges()
Dim table As DataTable = Me.DataSet1.Tables.Item("tblmeter")
Dim defaultView As DataView = table.DefaultView
Dim cell As New DataGridCell((defaultView.Table.Rows.Count - 1), 1)
Me.DataGrid1.CurrentCell = cell
txtno.Text = ""
txtturnover.Text = ""
txttotalwin.Text = ""
txtgamesplayed.Text = ""
txtcreditin.Text = ""
txtbillin.Text = ""
txthandpay.Text = ""
txtno.Focus()
I am using following code but it's not update records.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim current As DataRowView = DirectCast(Me.BindingContext.Item(Me.DataSet1.Tables.Item("tblmeter")).Current, DataRowView)
current.Delete()
Me.DataSet1.tblMeter.AcceptChanges()
Me.TblMeterTableAdapter.Update(Me.DataSet1.tblMeter)
End Sub
Code deletes records from datagrid but not updating.
Any help
© Stack Overflow or respective owner