Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27180

Failed to Enable Constraints (SQL/VB.NET issue)

$
0
0
I'm having a very annoying issue that I don't know how to fix. I've been working on a VB.NET/SQL school project for the past two weeks and have finally gotten to the very end (I think), but am running into a major hurtle that is really ticking me off. See, one part of my project has the user logging into the program to be able to access a series of tables that can be used for calculating payroll and other such things, however it's the logging in part that I'm stuck at; everything else is mostly done. Logging in has to have the program go out to the database to find the username and password, and match it to the user associated with the username and password given by the user. However, when I run this code...

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

...With these two SQL queries that go with the following adapter.query names...

GetUserName Query:
Code:

SELECT Login FROM Login
WHERE (Login = @Login)

GetPassword Query:
Code:

SELECT Password FROM Login
WHERE (Login = @Login)

...It keeps pinging me back with an error at the first If statement in my code, saying, "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." Odd thing is, I checked this in the database designer, and the query builder, and there's no visible NULL fields being shown when the query is run in Visual Studio 2012! I don't understand what I'm doing wrong in my coding! Can someone help?

Viewing all articles
Browse latest Browse all 27180

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>