Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   ASPX (.net) (http://www.forosdelweb.com/f78/)
-   -   No se ha inicializado la propiedad ConnectionString. (http://www.forosdelweb.com/f78/no-ha-inicializado-propiedad-connectionstring-551244/)

CieloEterno 24/01/2008 14:33

No se ha inicializado la propiedad ConnectionString.
 
Hola:

Estoy haciendo la validación de un usuario para la seguridad de un sistema.

Este es el procedimiento que estoy haciendo:

Código PHP:

        Protected Sub validar_Click(ByVal sender As ObjectByVal e As System.EventArgs)

            
Dim rsLectura As System.Data.Odbc.OdbcDataReader
            
            Dim lsLRsql 
As String "select usuario from tsm_usuario where usuario='" 
        
txt_usuario.Text.Trim "' and clave='" txt_passwd.Text.Trim "' and activo=1"

            
Response.Write("<font color=orange size=4>Query " lsLRsql "</font><br>")
            Try
                
ocdJL_Command.Dispose()
                
ocdJL_Command cn.putComand(lsLRsqlcLRcon)
                
Response.Write("<font color=gray size=4>AQUI-<br>")
                
rsLectura ocdJL_Command.ExecuteReader()
                Try
                    
rsLectura ocdJL_Command.ExecuteReader()
                Catch 
ex As Exception
                    
[B]rsLectura.Close() [/B]
                    
                    
Response.Write("<font color=purple size=4>VEAMOS-" ex.Message "<br>")
                    
rsLectura ocdJL_Command.ExecuteReader()

                
End Try
                
                If 
rsLectura.Read Then
                    Session
("vusuario") = rsLectura.Item("usuario")
                    
Session.Timeout 30
                    Response
.Write("<font color=red size=4>SESSION<br>")
                
End If
        
            Catch 
ex As Exception
                Session
("vusuario") = False
                Response
.Write("<font color=purple size=4>NO * SESSION-" ex.Message "<br>")
            
End Try


            If 
Session("vusuario") = True Then
                Response
.Write("<font color=darkblue size=4>Existe la sesión del 
            usuario</font>"
)
            Else
                
Response.Write("<font color=green size=4>NO Existe la sesión del 
            usuario</font>"
)
            
End If
            
        
End Sub 


En el momento en que cierro la conexion en el catch; obtengo:
http://mx.geocities.com/medianoche_lupus/02.JPG

Y lo que me manda en pantalla es esto:
http://mx.geocities.com/medianoche_lupus/01.JPG


La verdad, soy nueva en este tipo de programación, pero si alguien me puede decir que tipo de declaración o cómo debe ser hecha para rs Lectura, se los agradecería mucho.


Tengo definidas las variables que estoy ocupando en un archivo, declaradas asi:
Public cLRcon As New OdbcConnection


Gracias :arriba:

CieloEterno 24/01/2008 18:09

No se ha inicializado la propiedad ConnectionString.
 
He realizado algunas modificaciones:

Código PHP:

        Private Sub validar_Click(ByVal sender As ObjectByVal e As System.EventArgs)
            
            
Dim rsLectura As System.Data.Odbc.OdbcDataReader
            Dim query 
As String "select usuario from tsm_usuario where usuario='" txt_usuario.Text.Trim "' and clave='" txt_passwd.Text.Trim "' and activo=1"
            
            
Response.Write("<font color=orange size=4>Query " query "</font><br>")
            
Response.Write("<font color=orange size=4>ENTRA0 - abierto - *" cLRcon.State "* -  cerrado</font><br>")
            
            Try
                
Response.Write("<font color=orange size=4>ENTRA1 - abierto - *" cLRcon.State "* -  cerrado</font><br>")
                
cLRcon.Close()
                
Response.Write("<font color=orange size=4>ENTRA2 - abierto - *" cLRcon.State "* -  cerrado</font><br>")
                If 
cLRcon.State False Then
                    Response
.Write("<font color=orange size=4>ENTRA3 - cerrado -" cLRcon.State "- abierto</font><br>")
                    
''cLRcon.ConnectionString 
                    
                    
Response.Write("<font color=orange size=4>ENTRA5 - cerrado - abierto</font><br>")
                    
cLRcon.Open()
                    
Response.Write("<font color=orange size=4>ENTRA6 - cerrado - abierto</font><br>")
                Else
                    
Response.Write("<font color=orange size=4>ENTRA4 - cerrado - abierto</font><br>")
                
End If
                
                
ocdJL_Command.Dispose()
                
ocdJL_Command cn.putComand(querycLRcon)
                
Response.Write("<font color=gray size=4>AQUI-<br>")
                Try
                    
rsLectura ocdJL_Command.ExecuteReader()
                Catch 
ex As Exception
                    Response
.Write("<font color=purple size=4>OJOS-" ex.Message "<br>")
                    
rsLectura.Close()
                    
Response.Write("<font color=purple size=4>VEAMOS-" ex.Message "<br>")
                    
rsLectura ocdNA_Command.ExecuteReader()
                
End Try
                
                While 
rsLectura.Read
                    Session
("vusuario") = rsLectura.Item("usuario")
                    
Session.Timeout 30
                    Session
.Abandon()
                    
Response.Write("<font color=red size=4>SESSION<br>")
                
End While
                
                
'rsLectura.Close()
                
            Catch ex As Exception
                Response.Write("<font color=purple size=4>ULTIMO CATCH<br>")
                Response.Write("<font color=purple size=4>OJOS-**********<br>" + ex.Message + "<br>" + query + "--<br>")
            End Try
            

            '
If rsLectura.Read Then
            
'Session("vusuario") = rsLectura.Item("usuario")
            '
Session.Timeout 30
            
'Session.Abandon()
            '
Response.Write("<font color=red size=4>SESSION<br>")
            
'End If
            '
rsLectura.Close()
            
            If 
Session("vusuario") = True Then
                Response
.Write("<font color=darkblue size=4>Existe la sesión del usuario</font>")
            Else
                
Response.Write("<font color=green size=4>NO Existe la sesión del usuario</font>")
            
End If
            
        
End Sub 



Ahora, el error que obtengo es el siguiente:
No se ha inicializado la propiedad ConnectionString.

Al imprimir en pantalla, se muestran los siguientes avisos (response.write) que estoy colocando:

Query select usuario from tsm_usuario where usuario='administrador' and clave='123' and activo=1
ENTRA0 - abierto - *0* - cerrado
ENTRA1 - abierto - *0* - cerrado
ENTRA2 - abierto - *0* - cerrado
ENTRA3 - cerrado -0- abierto
ENTRA5 - cerrado - abierto
ULTIMO CATCH
OJOS-**********
No se ha inicializado la propiedad ConnectionString.
select usuario from tsm_usuario where usuario='administrador' and clave='123' and activo=1--
NO Existe la sesión del usuario


- Alguien sabe como Inicializar la propiedad ConnectionString? O cómo podrían soluciar este problema???

CieloEterno 25/01/2008 19:00

Resolución
 
Pues finalmente pude dar con la solución, agregué las siguentes líneas y todo quedo perfecto:

Código PHP:

        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load
            cLRcon 
cn.GetConnection()
            
cLRcon.Open()
        
End Sub 


¡¡¡Saludos¡¡¡


La zona horaria es GMT -6. Ahora son las 07:02.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.