CommandBuilder

  • Thread starter Thread starter Antonio Prieto
  • Start date Start date
A

Antonio Prieto

Hi:

how can I use the CommandBuilder object without a SelectCommad on
DataAdapter?

(my dataset must be read from a xml schema, not a result of a Select
statement).

Thanks,

Antonio Prieto.
 
Antonio Prieto said:
Hi:

how can I use the CommandBuilder object without a SelectCommad on
DataAdapter?

(my dataset must be read from a xml schema, not a result of a Select
statement).
The CommandBuilder requires a SelectCommand, but you don't have to use that
SelectCommand to fill your DataTable. You can fill it from XML, and then
use a DataAdapter with an attached CommandBuilder to save it to the a
database table.

Of course you will have to set the row states appropriately so the
DataAdapter knows what to do, and you must have a table in your database to
that matches the schema of the data.

David
 
Yes, but if I don´t use the Fill method of DataAdapter, seems like
CommandBuilder not create the SQL sentences of my DataAdapter (i.e.
InsertCommand = Nothing).

And if I execute Fill over my dataset, the virtual rows are crushed :D and
replaced by the new result of SelectCommand.

Can I make a SelectCommand without results (a Select query which returns 0
records)???

Thanks in advance,

Antonio.
 
Antonio Prieto said:
Yes, but if I don´t use the Fill method of DataAdapter, seems like
CommandBuilder not create the SQL sentences of my DataAdapter (i.e.
InsertCommand = Nothing).
You are mistaken. There is no relationship between the two.

The CommnadBuilder doesn't set the DataAdapter.InsertCommand, rather it is
invoked when DataAdapter.InsertCommand is null. If you want to see the
CommandBuilder's command, just set

da.InsertCommand = cb.CreateInsertCommand()
And if I execute Fill over my dataset, the virtual rows are crushed :D and
replaced by the new result of SelectCommand.

Can I make a SelectCommand without results (a Select query which returns 0
records)???

Sure, but that's not what you want to do. You do that when you want to
create an empty DataTable in your DataSet matching some table in your
database.

David
 
GetDeleteCommand returns only one of three keys of the primary key of my
table (i.e. "DELETE FROM table WHERE key1=?" instead of "DELETE FROM table
WHERE key1=? AND key2=? AND key3=?"). What happens?

Thanks in advance,

Antonio.
 
Back
Top