Zexor
Well-known member
- Joined
- Nov 28, 2008
- Messages
- 520
- Programming Experience
- 3-5
I have a dataset in the mainform
and i am trying to add a table to it from another form.
But it sometime give an "object reference is not set to an instance of an object" error when i add the table.
Used to work fine but now i dont know why it start to give that error. it seem to work half the time and error half the time.
VB.NET:
Dim ds As DataSet
Public Property dsValue() As DataSet
Get
Return ds
End Get
Set(ByVal value As DataSet)
ds = value
btSave.Enabled = True
End Set
End Property
VB.NET:
Dim newTable As DataTable
newTable = New DataTable("Name")
'codes to fill the table
VB.NET:
Delegate Sub updateDSCallback()
Private Sub updateDS()
Try
If Me.InvokeRequired Then
Dim d As New updateDSCallback(AddressOf updateDS)
Me.Invoke(d, New Object() {})
Else
formMain.dsValue.Tables.Add(newTable) 'error here
formMain.loadTree()
Me.Close()
End If
Catch ex As Exception
End Try
End Sub
Last edited: