dataadaptor update --- confused

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
 
P

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..
 
S

Sahil Malik [MVP]

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
 

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