Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way?
Message
 
To
27/11/2002 12:27:31
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Miscellaneous
Thread ID:
00727347
Message ID:
00727654
Views:
10
Jim,

Here is the criteria to use the CommandBuilder:

The CommandBuilder can generate updating logic if all the following are true:
• Your query returns data from only one table
• That table has a primary key
• The primary key is included in the results of your query

The disadvantages with using the CommandBuilder are:
• It doesn’t offer the best possible run-time performance.
• You can supply your own updating logic in code in less time than it takes the CommandBuilder to request and process the metadata required to generate similar updating logic.
• The CommandBuilder doesn’t offer options to let you control the updating logic that is generated.
• You can’t specify the type of optimistic concurrency you want to use.
• A CommandBuilder will not help you submit updates using stored procedures.



>Cathi,
>
> Could I use the command builder for updating my table?
>
>Jim
>
>>Jim,
>>
>>With ADO.NET, not much is done automatically. You need to set the CommandText property of the DataAdapter to the Command object that either has your stored procedure or your Update statement to execute against the backend.
>>
>>
>>Dim cmd As New SqlCommand("MyUpdateSP", cnn)
>>cmd.CommandType = CommandType.StoredProcedure
>>Dim prm As SqlParameter = _
>>	cmd.Parameters.Add("@Parm1", "MyValueToPass")
>>MyDA.UpdateCommand = cmd
>>
>>
>>Here is a link to a whitepaper I wrote about ADO.NET that explains how to perform these kinds of procedures:
>>
>>http://prenia.com/downloads.htm
>>
>>Click on "Introduction to ADO.NET for Visual FoxPro Developers"
>>
>>>Cathi,
>>>
>>>It says I have to set the commandtext property for the update command. I am assuming that the update method for the data adapter uses a stored procedure to do the update and automatically sets any parameters required by the stored proc. Is this correct?
>>>
>>>Jim
>>>
>>>>Jim,
>>>>
>>>>The sample code was if you needed to change the data other than in bound controls. In your case, just call the Update method of the DataAdapter to perform the update on the backend. Depending on how you are working with the DataGrid, you might need to call EndEdit method prior to performing the Update.
>>>>
>>>>>Hey Cathi,
>>>>>
>>>>> Thanks for the reply. The user will be making the changes in a datagrid. So can I just call the update command on the dataadapter or do I have to code the changes for all the fields like you are doing?
>>>>>
>>>>>Jim
>>>>>
>>>>>>Hi Jim,
>>>>>>
>>>>>>Look at Message #724589 for examples about how to update data in the DataSet to the backend.
>>>>>>
>>>>>>>Bonnie,
>>>>>>>
>>>>>>> I want to add data from an existing DataSet to a table that exists on your back-end database.
>>>>>>>
>>>>>>>Jim
>>>>>>>
>>>>>>>>Hi Jim,
>>>>>>>>
>>>>>>>>I'm not sure what you're asking ... do you want to add data from an existing DataSet to a table that exists on your back-end database? Or do you have existing data in a DataTable that you want to add to your DataSet?
>>>>>>>>
>>>>>>>>~~Bonnie
>>>>>>>>
>>>>>>>>
>>>>>>>>>All,
>>>>>>>>>
>>>>>>>>> I have a dataset that I want to add to an existing table selected by the user. Is there an easy way to do this? Are there any articles about this?
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform