我的错误在哪里?

时间:2010-06-08 13:09:55

标签: vb.net

我有连接到datagridview的表,我想通过使用文本框输入新数据。我有以下代码,但它给了我错误。如果你帮助我将不胜感激。错误消息是:使用“new”关键字创建对象实例

                Dim meter As DataTable = Me.DataSet1.Tables.Item("tblmeters")
                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()

1 个答案:

答案 0 :(得分:1)

看起来Me.DataSet1.Tables.Item("tblmeters")会返回Nothing。确保DataSet1确实包含表tblmeters