Problems with TableAdapters

W

WonderMan

Hello,

I am working on an application written with Visual Studio 2005 & C#. It
uses objects nammed TableAdapters, which I am not familiar with. The
database is a SQL Server 2000.

Sometimes, my application raises an exception with the message "Failed
to Enable Constraints", but my problem is that when debugging, I cant't
find a way to know which constraint is causing the problem. Is it a
database constraint or a dataset constraint ? Where can I get the value
of the parameters passed to the TableAdapter to try to execute the
stored procedure myself directly from SQL Server ?

I hope somebody could help me in understanding how I can debug this
application, and more specifically the TableAdapter points.

Thank you !
 
L

Linda Liu[MSFT]

Hi WonderMan,
I cant't find a way to know which constraint is causing the problem. Is
it a database constraint or a dataset constraint ?

As for database constraint, you can check it using the 'Check Constraint
Dialog Box'. For more information on how to use this dialog box, please
refer to the following MSDN document:

'Check Constraint Dialog Box'
http://msdn2.microsoft.com/en-us/library/8kc2z88w.aspx

As for dataset constraint, it refers to unique constraint and foreign key
constraint. You can create a unique constraint by defining a primary key in
a datatable or right-clicking on the datatable and choose 'Add | Key'
command.

The foreign key constraint is created by data relation between two
datatables.

In VS, open the dataset in the designer and double-click a data relation
between two datatables if any. In the 'Relation' dialog box, if the option
of 'Both Relation and Foreign Key constraint' or 'Foreign Key Constraint
Only' in the 'Choose what to create' part is selected, a foreign key
contraint is created.
Where can I get the value of the parameters passed to the TableAdapter to
try to execute the stored procedure myself directly from SQL Server ?

When calling TableAdapter's method to execute a store procedure, we have no
chance to get the value of the parameters passed to the TableAdapter.

I suggest that you use SqlCommand instead and set the CommandType property
of the SqlCommand object to 'StoredProcedure' and set the CommandText
property to the name of the stored procedure. Then you can get the value of
the parameters through the Parameters property of the SqlCommand object.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

WonderMan

Linda Liu[MSFT] a formulé la demande :
Hi WonderMan,

Hello,

Thank you for your very complete answer.
In fact, I discovered that the SELECT request I used when calling the
Fill method of the TableAdapter was incorrect as it returned several
records with the same ID, which created the problem with the
constraints.

Now, I corrected the request, and I get no more error messages.

Thank you again. :')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top