Add rows exception

matt09524

Well-known member
Joined
Sep 14, 2005
Messages
47
I get an "object reference not set to an instance of an object" error when trying to use control. Not sure whats going on, any ideas?

Code:
Private Sub addbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addbutton.Click
        Dim rc As DataRowCollection
        Dim newrow As DataRow
        Dim nrc(15) As Object
        nrc(0) = ""
        nrc(1) = ""
        nrc(2) = ""
        nrc(3) = ""
        nrc(4) = ""
        nrc(5) = ""
        nrc(6) = ""
        nrc(7) = ""
        nrc(8) = ""
        nrc(9) = ""
        nrc(10) = ""
        nrc(11) = ""
        nrc(12) = ""
        nrc(13) = ""
        nrc(14) = ""
        newrow = rc.Add(nrc)  <----- Object reference not set...
 
I have come into this problem throughout my adventure with this project. I am trying to not use the database wizard at all and because of that, I am forced to learn new stuff. I tried adding:

rc = dbdatacc.table.Rows

But it wont recognize "table" which is what I have been using as the datamember for all my binding. I tried using the table name, but aparently it doesnt recognize it. I dont have any problems binding or displaying the data, so I dont know what to do here.
 
Found an easier way to do this:

Code:
Dim myDataRowsCommandBuilder As OleDbCommandBuilder = New OleDbCommandBuilder(DbAdaptCC)
        Dim dr As DataRow
        dr = DbDataCC.Tables("table").NewRow()
        DbDataCC.Tables("table").Rows.Add(dr)
        Save()
        DbDataCC.Clear()
        DbAdaptCC.Fill(DbDataCC)
        Count()
 
Back
Top