T
tom c
I create 2 data OleDbDataAdapters, one with the wizard, and one in
code. I know the adapter created in code is OK because I use it to
fill a data table and I then look at one of the fields and the data is
there.
However, when I try to use the same SQL insert statement in the two
adapteres, the adapter created with the wizard works fine, but the
adapter created in code gives me an error "Object reference not set to
an instance of an object". The code is below. What am I doing wrong?
sqlA = "Select ID1, ID2 from CrossRef"
Dim daA As OleDbDataAdapter = New OleDbDataAdapter(sqlA, ConnA)
OleDbDataAdapter1.InsertCommand.CommandText = SQL 'this works fine
daA.InsertCommand.CommandText = SQL 'this gives an error
'OleDbDataAdapter1 is created by the wizard. daA is created in code.
code. I know the adapter created in code is OK because I use it to
fill a data table and I then look at one of the fields and the data is
there.
However, when I try to use the same SQL insert statement in the two
adapteres, the adapter created with the wizard works fine, but the
adapter created in code gives me an error "Object reference not set to
an instance of an object". The code is below. What am I doing wrong?
sqlA = "Select ID1, ID2 from CrossRef"
Dim daA As OleDbDataAdapter = New OleDbDataAdapter(sqlA, ConnA)
OleDbDataAdapter1.InsertCommand.CommandText = SQL 'this works fine
daA.InsertCommand.CommandText = SQL 'this gives an error
'OleDbDataAdapter1 is created by the wizard. daA is created in code.