Strongly Typed Dataset doesn't always auto generate DELETE and UPDATE stored procedures

I found this problem whilst creating a STD that included a many to many relationship between two tables.

I created a table consisting of the two foreign keys and appropriate constraints to support the relationship but VS2005 refused to create the UPDATE and DELETE stored procedures for me - and more importantly the DataTableAdapter methods to call the stored procedures.

One way around this I found on the web is to accept the default SQL statements which generates the c# code Ok and then edit the properties of the table adapter to use stored procs for each the commands (you will have to write two of them).

However, the root cause of this seems to be the relationship table not having a primary key.

Adding a primary key to the table allows VS2005 to generate stored procedures and methods as it would normally.

Note that the methods will be based on the primary key (i.e. there is no method to delete by the two foreign keys). There is nothing to stop you from adding this using the Add Query wizard - this requires you to write the SQL statement only.

Author Dave Howard

I have been involved in IT development for the last 10 years - a lot of it around desktop applications and telecoms.

Add Comment

Name
Comment
 

Your comment has been received and will be shown once it passes moderation.