无法在SQL中启用约束

时间:2013-12-06 23:56:50

标签: sql vb.net

我目前正在为学校做一些功课,差不多完成了,但是我遇到了尝试运行查询以匹配某些用户数据的问题。每次我运行调试过程时,都会出现“无法启用约束”的问题。一行或多行包含违反非null,唯一或外键约束的值。我不确定我做错了什么,或者如何克服它。我的查询或代码是否有问题?

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

这是我尝试用于适配器的SQL查询:

GetUserName查询:

SELECT Login FROM Login
WHERE (Login = @Login)

GetPassword查询:

SELECT Password FROM Login
WHERE (Login = @Login)

该功能中的参数与用户必须输入的用户名和密码条目相关。

0 个答案:

没有答案