Ciao a tutti,
spero mi possiate essere di aiuto.
Sto facendo un form che accedere autentificandosi, ma anche se user e password sono corretti mi dice che i dati sono errati.
Vi posto sotto il codice (in vbnet)
Vi ringrazio.codice:Dim objConnection As SqlConnection = New SqlConnection("Server=localhost\SQLEXPRESS;Database=VSA;Trusted_Connection=True") Dim objCommand As SqlCommand = New SqlCommand() objCommand.Connection = objConnection Dim psw As String If UsernameTextBox.Text.Trim.Length > 0 Then 'Controllo corrispondenza UTENTE/PASSWORD 'Query objCommand.CommandText = "SELECT Pass FROM Utenti WHERE Username = @userUtente" objCommand.Parameters.AddWithValue("userUtente", UsernameTextBox.Text) objConnection.Open() 'esecuzione query psw = objCommand.ExecuteScalar() 'Verifico se la password restituita dalla query e quella inserita coincidano If PasswordTextBox.Text = psw Then MessageBox.Show("AUTENTICAZIONE RIUSCITA!", "VSA - Autenticazione") Dim myPrincipale = New Principale myPrincipale.Show() 'Per chiudere la finestra Me.Close() Else MessageBox.Show("Password o User ERRATI: REINSERIRE, GRAZIE!", "VSA - Autenticazione") 'Incremento/Conto i tentativi contatore += 1 'Cancello la TextBox relativa alla Password e riposiziono il cursore UsernameTextBox.Clear() UsernameTextBox.Focus() PasswordTextBox.Clear() PasswordTextBox.Focus() 'Controllo i tentativi FALLITI If contatore = 3 Then 'Attivazione dell'evento AUTENTIFICAZIONE FALLITA MessageBox.Show("HAI ESAURITO LE PROVE!", "VSA - Autentificazione") Me.Close() End If End If End If objConnection.Close() .......
Buona serata.
Jade

Rispondi quotando

