473,658 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'Failed to enable constraints' Error on TableAdapter.Fi ll

abehm
35 New Member
Hey all,
I'm getting this error only when I have two similar entries in an login_audit table where the only difference is the actionhost and date. The query works fine in sqlserver. just not in the dataset.

What can I do to solve this problem?

The table structure is:
Expand|Select|Wrap|Line Numbers
  1. userID(Guid)
  2. username (nvarchar(50))
  3. firstname (nvarchar(50))
  4. lastname(nvarchar(50))
  5. email(nvarchar(MAX))
  6. isAdmin bit
  7. Action (nvarchar(20))
  8. ActionHost(nvarchar(30))
  9. Date datetime
  10.  
The entries:
Expand|Select|Wrap|Line Numbers
  1. 860B3D0F-D166-4388-82C0-EA5D77C2E231
  2. newuser
  3. New
  4. User
  5. new.user@company.com
  6. 1
  7. Logged In    
  8. LOCALMACHINE
  9. Apr  3 2008  3:24PM
  10.  
  11. 860B3D0F-D166-4388-82C0-EA5D77C2E231
  12. newuser
  13. New
  14. User
  15. new.user@company.com
  16. 1
  17. Logged In
  18. SERVERNAME
  19. Apr  3 2008  3:23PM
  20.  
And this is the stored procedure:

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [Security].[User_SelectDepartmentMembersLoginInfo]
  2.     @UserID uniqueidentifier
  3. AS
  4. BEGIN
  5. SELECT DISTINCT [Security].[User].UserID, Username, FirstName, LastName, Email, IsSysAdmin, [Action], ActionHost, CONVERT(varchar(MAX),MAX(Date)) AS LastLoggedIn
  6. FROM [Security].[User] LEFT OUTER JOIN Audit.[Login] ON [Security].[User].UserID = Audit.[Login].UserID LEFT OUTER JOIN [Security].DepartmentMembers ON [Security].[User].UserID = DepartmentMembers.UserID
  7.     WHERE ((@UserID IN (SELECT UserID FROM [Security].[User] WHERE IsSysAdmin = 'True'))
  8.     OR (DepartmentMembers.DepartmentID = (SELECT DepartmentID FROM [Security].DepartmentMembers WHERE UserID = @UserID AND IsDeptAdmin = 'True'))
  9.     AND (([Action] = 'Logged In') OR ([Action] IS NULL)))
  10.     GROUP BY [Security].[User].UserID, Username, FirstName, LastName, Email, IsSysAdmin, [Action], ActionHost
  11.     ORDER BY LastLoggedIn DESC, Username
  12.  
  13. END
  14.  
Apr 3 '08 #1
2 3325
ck9663
2,878 Recognized Expert Specialist
Hey all,
I'm getting this error only when I have two similar entries in an login_audit table where the only difference is the actionhost and date. The query works fine in sqlserver. just not in the dataset.

What can I do to solve this problem?

The table structure is:
Expand|Select|Wrap|Line Numbers
  1. userID(Guid)
  2. username (nvarchar(50))
  3. firstname (nvarchar(50))
  4. lastname(nvarchar(50))
  5. email(nvarchar(MAX))
  6. isAdmin bit
  7. Action (nvarchar(20))
  8. ActionHost(nvarchar(30))
  9. Date datetime
  10.  
The entries:
Expand|Select|Wrap|Line Numbers
  1. 860B3D0F-D166-4388-82C0-EA5D77C2E231
  2. newuser
  3. New
  4. User
  5. new.user@company.com
  6. 1
  7. Logged In    
  8. LOCALMACHINE
  9. Apr  3 2008  3:24PM
  10.  
  11. 860B3D0F-D166-4388-82C0-EA5D77C2E231
  12. newuser
  13. New
  14. User
  15. new.user@company.com
  16. 1
  17. Logged In
  18. SERVERNAME
  19. Apr  3 2008  3:23PM
  20.  
And this is the stored procedure:

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [Security].[User_SelectDepartmentMembersLoginInfo]
  2.     @UserID uniqueidentifier
  3. AS
  4. BEGIN
  5. SELECT DISTINCT [Security].[User].UserID, Username, FirstName, LastName, Email, IsSysAdmin, [Action], ActionHost, CONVERT(varchar(MAX),MAX(Date)) AS LastLoggedIn
  6. FROM [Security].[User] LEFT OUTER JOIN Audit.[Login] ON [Security].[User].UserID = Audit.[Login].UserID LEFT OUTER JOIN [Security].DepartmentMembers ON [Security].[User].UserID = DepartmentMembers.UserID
  7.     WHERE ((@UserID IN (SELECT UserID FROM [Security].[User] WHERE IsSysAdmin = 'True'))
  8.     OR (DepartmentMembers.DepartmentID = (SELECT DepartmentID FROM [Security].DepartmentMembers WHERE UserID = @UserID AND IsDeptAdmin = 'True'))
  9.     AND (([Action] = 'Logged In') OR ([Action] IS NULL)))
  10.     GROUP BY [Security].[User].UserID, Username, FirstName, LastName, Email, IsSysAdmin, [Action], ActionHost
  11.     ORDER BY LastLoggedIn DESC, Username
  12.  
  13. END
  14.  

Check your table. I think you have a PRIMARY KEY constraint that prevents you from inserting those duplicate rows.

-- CK
Apr 3 '08 #2
abehm
35 New Member
Check your table. I think you have a PRIMARY KEY constraint that prevents you from inserting those duplicate rows.

-- CK

lol.

I just saw that too!
I was just about to post to disregard that.
my bad.
Apr 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4801
by: Byron | last post by:
Using Visual Basic .Net 2003 Standard Edition Am attempting to join two oleDataAdapters. Right clicking on the second oleDataAdapter(the child) to preview the data, and then clicking the Fill Dataset button produces the MessageBox "Failed to enable constraints..." The DataSet is setup correctly, and I've reduced the Access Tables to only one record each, no empty fields. I know the relationship is correct. Is there a bug in VB.net that...
1
5148
by: Dotnet Gruven | last post by:
I've posted this in the adonet group, however it was suggested I might have better luck here.... ============================================================= I'm trying to use a typed dataset and ObjectDataSource binding to a SQLX db using a foreign key to filter the returned result set to display in a GridView. The error message in the subject line is generated when I try to bind the following GridView to the ObjectSource that follows...
5
7546
by: Programatix | last post by:
Hi, Have anyone ever benchmark the TableAdapter performance compared to DataTable's Load method? I found out that the DataTable's Load method is about 10x faster than TableAdapter's Fill method. I used the same SELECT query and DataSet (predefined), for both test. For the DataTable's Load method, we first need to create a DataReader.
3
7208
by: Mike | last post by:
Dear Group, When I add a DataTable to a Typed Dataset, and a TableAdapter to the DataTable, I am able to create methods to send updates directly to the database (GenerateDBDirectMethods), however when my TableAdapter Fill SQL contains a WHERE clause which looks up a field from another joined table, the Fill works perfectly, but I cannot Insert, Update or Delete using the TableAdapter. Does anyone know why this is?
2
10583
by: Rob Dob | last post by:
Hi, in the old days, pre .Net 2.0 I could just modify the SQLCommand of the SQlDataAdapter to reflect a different where clause and then issue a .Fill(), and Whamo!!! everything worked.. How am I to accomplish the same task using ..NET 2.0 and the NEW "TableAdapter", I can't see myself creating 100's of Queries using the wizard, is there anyway for me to just change the sql Where clause at runtime? I have the TableAdapter bound to a...
6
14609
by: Frieder Bürzele | last post by:
Hi, Im trying to integrate a rss feed into my page but struggle to fetch the dynamic generation of the rss feed If I type this into the browser as a result the xml file is shown as expected http://svnweb.tuxfamily.org/rss.php?repname=proaudio+%28ckpp%29&path=%2F&rev=0&sc=0&isdir=1 If I use it with a php-script which opens the url with fopen etc.
2
2330
by: Jeff | last post by:
I've been having this problem for weeks and its been stumping me. By the way, Im working with MS SQL 2000, ASP.NET2 and Visual Studio 2005. I am recieving an error, when executing a SELECT statement from an ObjectDataSource thorugh a strongly typed DataSet DAL: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. There are no foreign key constraints on my database, and...
1
2288
by: Bobby Edward | last post by:
This line of code... Using db As New dsUsersTableAdapters.useroptionsTableAdapter Produces this error: Out of range value adjusted for column 'EngrAlertForNewQuestions' at row 1 Any idea what this means?
4
21969
by: Bobby Edward | last post by:
I have an xsd dataset. I created a simple query called GetDataByUserId. I can preview the data fine! I created a very simple BLL function that calls it and returns a datatable. When I run the code I get.... ======================= Server Error in '/MyCompanyMyProject' Application.
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.