N3G4T1V3 0 Denunciar post Postado Agosto 22, 2005 Galera to tentando faze um sisteminha de login porem num to tendo mto sucesso.. eu fiz o seguinte código: Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnOk.Click Dim cn As New SqlClient.SqlConnection("workstation id=GENTILE;Data source=Gentile;Integrated Security=True;persist security info=False;initial catalog=CadBase;") cn.Open() Dim chkAdm As New System.Data.SqlClient.SqlCommand("Select * from Administrador where Login LIKE '%" & Replace(txtUsuario.Text, "'", "''") & "%' and Senha LIKE '%" & Replace(txtSenha.Text, "'", "''") & "%'", cn) Dim drAdm As System.Data.SqlClient.SqlDataReader drAdm = chkAdm.ExecuteReader() drAdm.Read() If drAdm.Read() Then FormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False) End If drAdm.Close() cn.Close() End Submas ele nem autentica e nem da erro.. por isso num sei o que ta errado.. se alguem souber da um help ae !! se tivé mta cgada num liga naum que comecei com .net a pouco tempo.. Compartilhar este post Link para o post Compartilhar em outros sites
rOcKLoCo 0 Denunciar post Postado Agosto 22, 2005 tente fazer assimPrivate Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnOk.ClickDim cn As New SqlClient.SqlConnection("workstation id=GENTILE;Data source=Gentile;Integrated Security=True;persist security info=False;initial catalog=CadBase;")cn.Open()Dim chkAdm As New System.Data.SqlClient.SqlCommand("Select * from Administrador where Login LIKE '%" & Replace(txtUsuario.Text, "'", "''") & "%' and Senha LIKE '%" & Replace(txtSenha.Text, "'", "''") & "%'", cn)Dim drAdm As System.Data.SqlClient.SqlDataReaderdrAdm = chkAdm.ExecuteReader()If drAdm.Read() ThenFormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False)End IfdrAdm.Close()cn.Close()End Sub Compartilhar este post Link para o post Compartilhar em outros sites
N3G4T1V3 0 Denunciar post Postado Agosto 22, 2005 Amigo não sei se eu que não estou enchergando ou você que esqueceu de alterar o código?! pq num vi nada direferente no que você postou.. tente fazer assim Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnOk.Click Dim cn As New SqlClient.SqlConnection("workstation id=GENTILE;Data source=Gentile;Integrated Security=True;persist security info=False;initial catalog=CadBase;") cn.Open() Dim chkAdm As New System.Data.SqlClient.SqlCommand("Select * from Administrador where Login LIKE '%" & Replace(txtUsuario.Text, "'", "''") & "%' and Senha LIKE '%" & Replace(txtSenha.Text, "'", "''") & "%'", cn) Dim drAdm As System.Data.SqlClient.SqlDataReader drAdm = chkAdm.ExecuteReader() If drAdm.Read() Then FormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False) End If drAdm.Close() cn.Close() End Sub <{POST_SNAPBACK}> Compartilhar este post Link para o post Compartilhar em outros sites
rOcKLoCo 0 Denunciar post Postado Agosto 23, 2005 seu código: Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnOk.Click Dim cn As New SqlClient.SqlConnection("workstation id=GENTILE;Data source=Gentile;Integrated Security=True;persist security info=False;initial catalog=CadBase;") cn.Open() Dim chkAdm As New System.Data.SqlClient.SqlCommand("Select * from Administrador where Login LIKE '%" & Replace(txtUsuario.Text, "'", "''") & "%' and Senha LIKE '%" & Replace(txtSenha.Text, "'", "''") & "%'", cn) Dim drAdm As System.Data.SqlClient.SqlDataReader drAdm = chkAdm.ExecuteReader() drAdm.Read() ----> removi essa linha If drAdm.Read() Then FormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False) End If drAdm.Close() cn.Close() End Sub Compartilhar este post Link para o post Compartilhar em outros sites
N3G4T1V3 0 Denunciar post Postado Agosto 23, 2005 Tirei e mesmo assim ele num da erro mas tbm num faz nada.. Compartilhar este post Link para o post Compartilhar em outros sites
rOcKLoCo 0 Denunciar post Postado Agosto 23, 2005 você tem certeza q ele está encontrando algum registro??? para testar tente fazer assim nessa parte: de: If drAdm.Read() ThenFormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False)End If para: If drAdm.Read() ThenFormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False)elseresponse.write("Login/Senha inválidos")End If Compartilhar este post Link para o post Compartilhar em outros sites
N3G4T1V3 0 Denunciar post Postado Agosto 23, 2005 Percebi que ele ta buscando no banco e ta autorizando ou não porém o código: FormsAuthentication.RedirectFromLoginPage(txtUsuario.Text, False)num ta funcionando, ele teria que redirecionar para a página que o usuário pediu e gravar o cookie que ele está autenticado.. Compartilhar este post Link para o post Compartilhar em outros sites
N3G4T1V3 0 Denunciar post Postado Agosto 23, 2005 Consegui era no web config o problema ele tava assim:<deny users="*" />ai só mudei para <deny users="?" /> Compartilhar este post Link para o post Compartilhar em outros sites