View Single Post
  #1 (permalink)  
Old 06-13-2007, 9:00 AM
ninjaimp ninjaimp is offline
VB.NET Forum Enthusiast
.NET Framework: .NET 2.0
 
Join Date: Jun 2007
Posts: 70
Reputation: 37
ninjaimp is on a distinguished programming path ahead
Exclamation System.NullReferenceException error!

Hi

I am very new to vb.net and still trying to get my head around it. I am trying to connect to an access db and then update a table with some test info

my code is:

Code:
Dim con As New OleDb.OleDbConnection
        Dim sql As String
        Dim ds As New DataSet
        Dim da As OleDb.OleDbDataAdapter
        Dim MakeTableSQL As String
        Dim MySql As String
        Dim MySql2 As String
        Dim MySql3 As String

        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\email.mdb"

        sql = "SELECT * FROM Email"
        da = New OleDb.OleDbDataAdapter(sql, con)

        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim dsNewRow As DataRow

        dsNewRow = ds.Tables("Labels").NewRow()

        dsNewRow.Item("Body") = "Test"

        ds.Tables("Labels").Rows.Add(dsNewRow)

        da.Update(ds, "Labels")

        MsgBox("New Record added to the Database")
eveytime i run the code i get the error 'System.NullReferenceException'

i wondered if anyone could help?
Reply With Quote