Ciao ragazzi.
Nell'eseguire il mio login, il debug mi dà un errore che non riesco a capire..mi potete aiutare per favore???
Vi posto il codice del login:
l'errore me lo dà evidenziando in verde la stringa "If myCommand.ExecuteScalar = "user" Then" del codice sopra elencato e dicendomi questo: Errore di sintassi nella proposizione FROM...quale sarebbe questo errore??codice:Imports System.Data.OleDb Imports System.Data Partial Class Site_Login Inherits System.Web.UI.Page Protected Sub btn_login_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_login.Click Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=" + Server.MapPath("..\db\dbNautica.mdb").ToString Dim myConnection As New OleDbConnection(ConnectionString) Dim user As String = txtusername.Text Dim pass As String = txtpassword.Text Dim sql As String = "SELECT ruolo FROM Utente" sql = sql + "WHERE NomeUtente = '" + user + "' AND Password = '" + pass + "'" Dim myCommand As New OleDbCommand(sql, myConnection) myConnection.Open() If myCommand.ExecuteScalar = "user" Then Session("nomeutente") = user Session("Ruolo") = "user" FormsAuthentication.Authenticate(user, pass) FormsAuthentication.RedirectFromLoginPage(user, False) Dim userIDsql As String userIDsql = "SELECT ID, Cognome, Nome FROM Utente WHERE NomeUtente = """ + Session("nomeutente") + """;" Dim command As New OleDbCommand(userIDsql, myConnection) Dim reader As OleDbDataReader reader = command.ExecuteReader() While reader.Read() Session("IDUtente") = reader.Item(0) Session("credenzialiUtente") = reader.Item(1) + " " + reader.Item(2) End While myConnection.Close() ElseIf myCommand.ExecuteScalar = "admin" Then Session("Ruolo") = "admin" FormsAuthentication.Authenticate(user, pass) FormsAuthentication.RedirectFromLoginPage(user, False) Response.Redirect("../Protect/admin/menuAdmin.aspx") myConnection.Close() Else messaggio.Visible = True messaggio.Text = "Nome utente o password errati." myConnection.Close() End If End Sub End Class

Rispondi quotando
