Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Problems with TableAdapters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WonderMan - 27 Feb 2008 17:53 GMT
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 !
Linda Liu[MSFT] - 28 Feb 2008 09:26 GMT
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.
WonderMan - 28 Feb 2008 10:52 GMT
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.  :')

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.