G
Guest
I searched some of the previous posts and cam eup with some code I thought
would work for my application, but when I ran it, I got the following error:
An unhandled exception of type 'System.NullReferenceException' occurred in
DBLoad.exe
Additional information: Object reference not set to an instance of an object.
Here's the code (it may look familiar!) The line with the trailing
astericks is the offending line.
Private Sub DatabaseFunction()
' Variables
Dim ConnAccess As OleDbConnection
Dim da As OleDbDataAdapter
Dim cmd As OleDbCommandBuilder
Dim ds As DataSet
Dim strConn As String
' Some flat file processing to poplate the string fields
' Write the record to the database
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =
c:\test.mdb"
ConnAccess = New OleDbConnection(strConnection)
Dim dr As DataRow = ds.Tables("ResidentBirthday").NewRow **********
With dr
.Item(0) = strUnit
.Item(1) = strResidentFullName
.Item(3) = strUnitPhone
.Item(4) = strWorkPhone
End With
ds.Tables("ResidentBirthday").Rows.Add(dr)
da.Update(ds, "ResidentBirthday")
ds.AcceptChanges()
End Sub
What did I copy wrong?????
would work for my application, but when I ran it, I got the following error:
An unhandled exception of type 'System.NullReferenceException' occurred in
DBLoad.exe
Additional information: Object reference not set to an instance of an object.
Here's the code (it may look familiar!) The line with the trailing
astericks is the offending line.
Private Sub DatabaseFunction()
' Variables
Dim ConnAccess As OleDbConnection
Dim da As OleDbDataAdapter
Dim cmd As OleDbCommandBuilder
Dim ds As DataSet
Dim strConn As String
' Some flat file processing to poplate the string fields
' Write the record to the database
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =
c:\test.mdb"
ConnAccess = New OleDbConnection(strConnection)
Dim dr As DataRow = ds.Tables("ResidentBirthday").NewRow **********
With dr
.Item(0) = strUnit
.Item(1) = strResidentFullName
.Item(3) = strUnitPhone
.Item(4) = strWorkPhone
End With
ds.Tables("ResidentBirthday").Rows.Add(dr)
da.Update(ds, "ResidentBirthday")
ds.AcceptChanges()
End Sub
What did I copy wrong?????