Last post Oct 20, 2010 01:49 AM by Wencui Qian - MSFT
Oct 14, 2010 11:15 AM|sconard|LINK
I have a simple table with a primary key in sql 2005 db. If I use the TableAdapter Configuration Wizard in VS2010 to Create New Stored Procedures, it offers by default to generate Insert, Update and Delete stored procedures. I supply the simplest of sql
statements for the wizard to generate the rest of the code
SELECT field1, field2
And the wizard only generates code for Insert and Select procedures. The connection is performed with an admin account and I cannot find a reason why the Update and Delete procedures are not generated.
TableAdapter Configuration Wizard
Oct 14, 2010 06:32 PM|DarrellNorton|LINK
You need a primary key defined on that table. If there is no primary key, then it will not create update or delete statements.
Oct 15, 2010 01:47 PM|sconard|LINK
As noted in original post: Primary key is defined in sql. Allow me to recite my steps.
Create simple table in sql 2005 with field1 set as primary key.
Add dataset to visual studio 2010 project
With dataset designer open, click on tableAdapter in toolbox and follow wizard.
Supply simple select statement for wizard to generate code
Wizard does not generate update or delete scripts.
tableAdapter Wizard Failure
Oct 19, 2010 03:43 AM|Wencui Qian - MSFT|LINK
What is the exact meaning by "update and delete procedures are not generated"? Please double check it like this:
1) Right click on the TableAdapter.
2) Select "Configuration" option.
3) Select "Advanced Options".
4) Check whether "Generate Insert, Update and Delete Statements" option is selected.
If it's selected, you can use the update and delete method in source code. Of course, you can also write your own sql query for update and delete.
Oct 19, 2010 09:24 AM|sconard|LINK
As written in original post: Generate Insert, Update and Delete option is selected by default.
I have visually verified its selection prior to finishing wizard.
The desire is to avoid the arduous task of writing an update query that has over 50 parameters when the wizard indicates that it will do so without effort. There are certainly plenty of sql scripts that will do this (from table structure) as well. I was hoping
to use VS for this task and want to understand why it is failing at what it is designed to produce.
Oct 20, 2010 01:49 AM|Wencui Qian - MSFT|LINK
If you've checked the dataset and ensure the option is selected, you can call the Update method to complete what you want. Also, you can add a update query to pass in each parameters without writing any code: Right click on the tableadapater, Select "Add-->query"
and then choose "Update". The parameterized query will be added in automatically.