473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

'Failed to enable constraints' Error on TableAdapter.Fill

abehm
35
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 3313
ck9663
2,878 Expert 2GB
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
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
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...
1
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...
5
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....
3
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),...
2
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...
6
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...
2
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...
1
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.