Saturday, November 17, 2007

Are your strongly typed datasets not generating Delete & Insert statements & stored procedures?

This is something very simple you may or may not have come across in your day-to-day dot net programming life. There are times when we use those entirely beautiful, full of great things, code-saving datasets in asp.net to make our lives easier. However, you may have noticed that there are times when the strongly typed dataset does not generate all of the required stored procedures even though you specified them when you set up the table adapter.

The reason is simple and the fix is simple too. The strongly typed dataset looks at your table to see if a primary key is defined. If your primary key is defined, then your delete and insert functions will be created. If you have been very bad and deserve a spanking and HAVE NOT defined a primary key, you will not see your Delete and Insert statements or stored procedures.

Now wasn't that simple?

Smooches,

Kila

Summary

Error: Delete & Insert stored procedures and statements are not generated in a strongly typed dataset
Cause: A Primary key is undefined on your table.

Fix: Define a primary key on your table and then define your dataset.

Comments anyone?

No comments: