PC Review


Reply
Thread Tools Rate Thread

CommandBuilder

 
 
Antonio Prieto
Guest
Posts: n/a
 
      22nd Nov 2004
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.



 
Reply With Quote
 
 
 
 
David Browne
Guest
Posts: n/a
 
      22nd Nov 2004

"Antonio Prieto" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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


 
Reply With Quote
 
Antonio Prieto
Guest
Posts: n/a
 
      22nd Nov 2004
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 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.




"David Browne" <davidbaxterbrowne no potted (E-Mail Removed)> escribió en el
mensaje news:ukEMG$(E-Mail Removed)...
>
> "Antonio Prieto" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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
>
>




 
Reply With Quote
 
David Browne
Guest
Posts: n/a
 
      22nd Nov 2004

"Antonio Prieto" <(E-Mail Removed)> wrote in message
news:Ou$(E-Mail Removed)...
> 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 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


 
Reply With Quote
 
Antonio Prieto
Guest
Posts: n/a
 
      23rd Nov 2004
Thanks, David. This seems to work.

Regards,

Antonio Prieto.

"David Browne" <davidbaxterbrowne no potted (E-Mail Removed)> escribió en el
mensaje news:O%(E-Mail Removed)...
>
> "Antonio Prieto" <(E-Mail Removed)> wrote in message
> news:Ou$(E-Mail Removed)...
>> 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
>> 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
>
>




 
Reply With Quote
 
Antonio Prieto
Guest
Posts: n/a
 
      23rd Nov 2004
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.


"Antonio Prieto" <(E-Mail Removed)> escribió en el
mensaje news:(E-Mail Removed)...
> Thanks, David. This seems to work.
>
> Regards,
>
> Antonio Prieto.
>
> "David Browne" <davidbaxterbrowne no potted (E-Mail Removed)> escribió en
> el mensaje news:O%(E-Mail Removed)...
>>
>> "Antonio Prieto" <(E-Mail Removed)> wrote in
>> message news:Ou$(E-Mail Removed)...
>>> 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
>>> 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
>>
>>

>
>
>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CommandBuilder Question... MobileBoy36 Microsoft Dot NET Compact Framework 2 1st Feb 2006 07:52 PM
Done with CommandBuilder tascienu@ecoaches.com Microsoft ADO .NET 5 12th Sep 2005 07:41 AM
How can this be? CommandBuilder w/ OleDb =?Utf-8?B?R2FyeUZl?= Microsoft ADO .NET 5 16th Dec 2004 05:13 AM
CommandBuilder question Sébastien Microsoft ADO .NET 1 17th Feb 2004 06:04 PM
Re: CommandBuilder question William Ryan eMVP Microsoft ADO .NET 2 16th Feb 2004 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:04 PM.