dataadaptor update --- confused

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

OK I'm lost.... Hope I can describe this that you will understand what I'm
taking about.

I have an Oracle dataset and I've inserted some rows into it, I now want to
update the database. I managed to do this by going thru each row and
creating an oraclecommand, passing the parameters and executenonquery, and
it works.

However instead of doing all that looping thru rows, I believe I can use the
dataadapter UPDATE method to do this for me (and it may be faster?)

Here is what I've done

Built an oraclecommand with INSERT INTO TEST (field1, field2) VALUES (?,?)
Set my dataadaptors insertcommand to the oraclecommand above
Added datamappings for my two columns

BUT..... I'm confused to how I create parameters. When updating row by row
I would do thecmd.Parameters.Add(colname, "THEVALUE"), but in this case I
don't have a value because it's based on the row currently being inserted.

How do I create the parameters? I tried this thecmd.Parameters.Add(colname,
oracleds.Tables(0).Columns(colloopy).DataType), but I get "Object must
implement Iconvertable"


I hope this makes sense to someone, sorry for the long post
Paul
 
Thanks but in my case I'm trying to build the parameters dynamically based
on the column type in the dataset. That's my problem I think..
 
Paul,

You are getting that IConvertible error because the specified data type on
the parameter is incorrect - try specifying a strict OracleDbType (there
should be such an enumeration under the OracleClient).

In order to specify the "Value" - you need to specify the "SourceColumn"
property on the Parameter - the dataadapter will then put the value in for
you.

HTH :-)

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 
Back
Top