I'm currently working on a bit of homework for school, and am almost done, however I've got an issue with trying to run a query to match some user data. Every time I run the debugging process, it comes up time and again with the issue of 'Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.' I'm not sure what I'm doing wrong, or how to get past it. Is there something up with my query, or with my code?
Public Class Login_Processing
Dim adapter As New RRBCDataSetTableAdapters.LoginTableAdapter
Dim blnPass As Boolean
Public Function Login(ByVal Username As String, ByVal Password As String) As Boolean
Try
If adapter.GetUserNames(Username).ToString = "VViscioni" Or _
adapter.GetUserNames(Username).ToString = "Whiter" Then
If adapter.GetPassword(Username).ToString = Password Then
frmMain.tsiAdmin.Enabled = True
frmMain.tsiEAdmin.Enabled = True
frmMain.tsiEPlayer.Enabled = True
MessageBox.Show("Welcome back!")
blnPass = True
Else
MsgBox("Is this a new user?", MsgBoxStyle.YesNo)
If vbYes Then
AddAUser.ShowDialog()
Else
MessageBox.Show("Please re-input your password.")
blnPass = False
End If
End If
ElseIf adapter.GetUserNames(Username).ToString = Username Then
If adapter.GetPassword(Username).ToString = Password Then
frmMain.tsiEPlayer.Enabled = True
MessageBox.Show("Welcome to the Roadrunners Baseball Club!")
blnPass = True
Else
MessageBox.Show("Please re-input your password.")
blnPass = False
End If
End If
Catch ex As Exception
MessageBox.Show("Please re-input your username/password.")
blnPass = False
End Try
Return blnPass
End Function
End Class
Here's the SQL queries I'm trying to use for the adapters:
GetUserName Query:
SELECT Login FROM Login
WHERE (Login = @Login)
GetPassword Query:
SELECT Password FROM Login
WHERE (Login = @Login)
The parameters in the function relate to a Username and Password entry the user has to input.