0
我不斷收到此錯誤驗證登錄:system.data.sqlclient.sqlcommand並不能連接到我爲了驗證我的登錄 無法在VB
Imports System.Data.SqlClient
Public Class Login
Dim strSql As String = "Data Source=FILIPA-PC\SQLEXPRESS;Initial Catalog=NIC;Integrated Security=True;"
Dim connection As SqlConnection
Dim SQL As SqlCommand
Dim str As String
Dim perfil As String
Public Sub BtnLogin_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click
Dim username, password As String
username = UsernameTextBox.Text
password = PasswordTextBox.Text
str = "SELECT Tipo_Perfil FROM Perfil INNER JOIN Login ON Perfil.ID_Perfil =Login.ID_Utilizador INNER JOIN Utilizador ON Utilizador.ID_Utilizador=Login.ID_Utilizador WHERE username = '" + username + "' AND passeword = '" + password + "'"
connection = New SqlConnection(strSql)
connection.Open()
SQL = New SqlCommand(str, connection)
perfil = ""
'perfil = SQL.ExecuteScalar.ToString
perfil = Convert.ToString(SQL)
MessageBox.Show(perfil)
connection.Close()
Select Case (perfil)
Case "Administrador"
Administrador.Show()
Case "Utilizador"
Utilizador.Show()
End Select
End Sub
End Class
我不知道是什麼問題是,無法連接到我的數據庫來驗證登錄,順便說一句,這些字段都是正確的。沒有錯誤有
'System.Data.SqlClient.SqlCommand'不是錯誤。你應該找到併發布實際的錯誤信息 – ugo