newrow to Oracle dataset

J

Joe Coder

Hi All,

I am trying to add a new row to an existing table in my database. I
get the error "An unhandled exception of type
'System.NullReferenceException' occurred in OracleConnectionTest.exe
Additional information: Object reference not set to an instance of an
object." when I try to define a new row.

I have been able to add a new row in MSDE but when I try to adapt my
sub to Oracle it bombs at "myDataRow = ds.Tables(BayID).NewRow()".

Any help will be appreciated.

Thanks,

Here is my code:

Sub UseDataSet(ByVal BayID As String)

BayID = "Template"

Dim ds As New DataSet
Dim da As New OracleDataAdapter("select * from BAY_" & BayID,
"data source=WAREHOUSE;" & _
"user id=ODBCUSER;password=MAYFLOWER")
Dim bld As New OracleCommandBuilder(da)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey

da.Fill(ds, "BAY_" & BayID)
Dim myDataRow As DataRow
myDataRow = ds.Tables(BayID).NewRow()
myDataRow("REC_NUM") = 256
myDataRow("PALETTEID") = "110203005"
myDataRow("RUNDATE") = "11/2/2003"
ds.Tables(BayID).Rows.Add(myDataRow)
da.Update(ds, "BAY_" & BayID)

End Sub
 
M

Miha Markic

Hi Joe,

Since you let DataAdapter to create a table it will name it "BAY_"+BayId
(same as table in sql statament) and not only BayId.
ds.Tables("BAY_"+BayID).NewRow()".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top