Arrasted 0 Denunciar post Postado Outubro 15, 2005 ERO The ConnectionString property has not been initialized. <%@ Page Language="VB" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <script runat="server"> Private Sub btnAcessar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim CN As New SqlConnection Dim CM As SqlCommand Dim DR As SqlDataReader Dim strCN As String strCN = "Data Source=(local); Database=global; User id=*****; Password=*****" Dim strSql As String strSql = "select usuario_nome, usuario_tipo FROM usuarios WHERE " strSql &= "usuario_email= '" & Me.txtUsuario.Text.Trim strSql &= "' and usuario_senha = '" & Me.txtSenha.Text.Trim & "'" Try CN = New SqlConnection CN.Open() CM = New SqlCommand(strSql, CN) DR = CM.ExecuteReader() If DR.Read Then Session("nome") = DR("usuario_nome") Response.Redirect("Default.aspx?tipo=" & DR("usuario_tipo")) Else Me.lblErro.Text = "Usuário ou Senha Incorretos" End If Catch ex As Exception Me.lblErro.Text = ex.Message End Try End Sub Private Sub btnLimpar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Me.txtUsuario.Text = String.Empty Me.txtSenha.Text = String.Empty End Sub </script> Botao acessar <asp:Button ID="btnAcessar" runat="server" Text="Acessar" OnClick="btnAcessar_Click" /> Valeu Compartilhar este post Link para o post Compartilhar em outros sites
Juliano.net 2 Denunciar post Postado Outubro 15, 2005 Você não informou ao objeto Connection a string de conexão.... <%@ Page Language="VB" %><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %><script runat="server">Private Sub btnAcessar_Click(ByVal sender As Object, ByVal e As System.EventArgs)Dim CN As SqlConnection Dim CM As SqlCommand Dim DR As SqlDataReaderDim strCN As String strCN = "Data Source=(local); Database=global; User id=*****; Password=*****"Dim strSql As StringstrSql = "select usuario_nome, usuario_tipo FROM usuarios WHERE "strSql &= "usuario_email= '" & Me.txtUsuario.Text.TrimstrSql &= "' and usuario_senha = '" & Me.txtSenha.Text.Trim & "'"Try CN = New SqlConnection(strCN)CN.Open()CM = New SqlCommand(strSql, CN)DR = CM.ExecuteReader()If DR.Read Then Teste com as alterações acima... Compartilhar este post Link para o post Compartilhar em outros sites
Arrasted 0 Denunciar post Postado Outubro 17, 2005 Valeu. deu certo Compartilhar este post Link para o post Compartilhar em outros sites