Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    chiusura connessioni errata

    ciao a tutti mi sono incasinato con le chiusure delle connessioni e se le abilito non mi funziona niente....vi posto il codice:

    ho due connessioni a due db conn e adoCon
    mi date una controllata...grazie....
    codice:
    If Request.QueryString("step") = "2" THEN 
    	authorized = False
    	username = Trim(Request.Form("username"))
    	password = Trim(Request.Form("password"))
    
    	If Len(username) = 0 Or Len(password) = 0 Then
    		Response.Write "Please insert usename and password"
    	Else
    		username = Replace(username,"'","''")
    		password = Replace(password,"'","''")
    
    		sql = "SELECT username, password FROM user " &_
    		"WHERE username = '" & username & "' " &_
    		"AND password = '" & password & "'"
    
    		Set Rs = Conn.Execute(sql)
    
    		If Rs.EOF Then
    			Response.Write "Incorrect Login!"
    		Else
    			'Utente moderatore , mentre Utente admin ha una vsession aggiuntiva
    			Session.TimeOut = 15 
    			authorized = True
    			Session("authorized") = authorized 
    
    			set tbuser=Conn.execute("select * from user WHERE username = '" & username & "'")
    			struserautority = tbuser("autority")
    			strname 		= tbuser("name")
    			struser 		= tbuser("username")
    			strtime 		= Time()
    			strdate 		= Date()
    			strip			= Request.ServerVariables("REMOTE_ADDR")
    			strhost			= Request.ServerVariables("REMOTE_HOST")
    
    			Set rs1 = Server.CreateObject("ADODB.Recordset") 
    			sql1 = "INSERT INTO log ([autority], [name], [username], [timein], [datein], [ip], [host]) VALUES('"&struserautority&"', '"&strname&"', '"&struser&"', '"&strtime&"', '"&strdate&"', '"&strip&"', '"&strhost&"')" 
    			conn.execute sql1 
    			'rs1.Close
    		    'set rs1=Nothing
    			conn.Close
    		    set conn=Nothing
    			
    			If struserautority = "admin" or struserautority = "mod" then
    				If struserautority = "admin"  then
    					Session.TimeOut = 15 
    					loginadmin = True
    					Session ("loginadmin") = loginadmin
    				End If
    				Set rs_login = Server.CreateObject ("ADODB.RecordSet")
    				strSQL = "SELECT * FROM tbl_authors WHERE authority='" & struserautority & "' "
    				rs_login.open strSQL,adoCon
    				Response.Cookies("Login")("userCode") = rs_login("code")
    				struserautority = rs_login("authority")
    				strname 		= rs_login("fullname")
    				struser 		= rs_login("name")
    				stremail		= rs_login("email")
    				strtime 		= Time()
    				strdate 		= Date()
    				strip			= Request.ServerVariables("REMOTE_ADDR")
    				strhost			= Request.ServerVariables("REMOTE_HOST")
    				rs_login.Close
    		    	set rs_login=Nothing
    				
    				Set rs3 = Server.CreateObject("ADODB.Recordset") 
             		sql3 = "INSERT INTO log ([autority], [fullname], [username], [email], [timein], [datein], [ip], [host]) VALUES('"&struserautority&"', '"&strname&"', '"&struser&"', '"&stremail&"', '"&strtime&"', '"&strdate&"', '"&strip&"', '"&strhost&"')" 
    				adoCon.execute sql3 
    				'rs3.Close
    		    	'set rs3=Nothing
    			End If
    			
    		End If
    		
    	End If
    	'Rs.Close
    		'Set Rs = Nothing
    		'Conn.Close
    		'Set Conn = nothing
    	If authorized Then
    		Response.Redirect "restricted_area.asp"
    	End If
    End If

  2. #2
    ??????

    suggerimenti :master:

  3. #3
    ho fatto alcune modifiche ma sono sempre al punto di partenza.. ...quando tolgo il commento alle righe che chiudono i recordset mi da il se guente errore:

    Tipo di errore:
    ADODB.Recordset (0x800A0E78)
    L'operazione non è consentita se l'oggetto è chiuso.
    /restricted_area/frmLogin.asp, line 158



    codice:
    If Request.QueryString("step") = "2" THEN 
    	authorized = False
    	username = Trim(Request.Form("username"))
    	password = Trim(Request.Form("password"))
    
    	If Len(username) = 0 Or Len(password) = 0 Then
    		Response.Write "Please insert usename and password"
    	Else
    		username = Replace(username,"'","''")
    		password = Replace(password,"'","''")
    
    		sql = "SELECT username, password FROM user " &_
    		"WHERE username = '" & username & "' " &_
    		"AND password = '" & password & "'"
    
    		Set Rs = Conn.Execute(sql)
    
    		If Rs.EOF Then
    			Response.Write "Incorrect Login!"
    		Else
    			'Utente admin ha una vsession aggiuntiva
    			Session.TimeOut = 15 
    			authorized = True
    			Session("authorized") = authorized 
    
    			set tbuser=Conn.execute("select * from user WHERE username = '" & username & "'")
    			struserautority = tbuser("autority")
    			strname 		= tbuser("name")
    			struser 		= tbuser("username")
    			strtime 		= Time()
    			strdate 		= Date()
    			strip			= Request.ServerVariables("REMOTE_ADDR")
    			strhost			= Request.ServerVariables("REMOTE_HOST")
    			tbuser.Close
    		    set tbuser=Nothing
    
     			Set rs1 = Server.CreateObject("ADODB.Recordset") 
    			sql1 = "INSERT INTO log ([autority], [name], [username], [timein], [datein], [ip], [host]) VALUES('"&struserautority&"', '"&strname&"', '"&struser&"', '"&strtime&"', '"&strdate&"', '"&strip&"', '"&strhost&"')" 
    			rs1.open sql1,conn
    			' rs1.Close
    		   ' set rs1=Nothing
    			conn.Close
    		    set conn=Nothing
    			
    			If struserautority = "admin" or struserautority = "mod" then 'Utente admin ha una vsession aggiuntiva ed assieme al mod un log aggiuntivo nel db users
    				If struserautority = "admin"  then
    					Session.TimeOut = 15 
    					loginadmin = True
    					Session ("loginadmin") = loginadmin
    				End If
    				Set rs_login = Server.CreateObject ("ADODB.RecordSet")
    				strSQL = "SELECT * FROM tbl_authors WHERE authority='" & struserautority & "' "
    				rs_login.open strSQL,adoCon
    				Response.Cookies("Login")("userCode") = rs_login("code")
    				struserautority = rs_login("authority")
    				strname 		= rs_login("fullname")
    				struser 		= rs_login("name")
    				stremail		= rs_login("email")
    				strtime 		= Time()
    				strdate 		= Date()
    				strip			= Request.ServerVariables("REMOTE_ADDR")
    				strhost			= Request.ServerVariables("REMOTE_HOST")
    				rs_login.Close
    		    	set rs_login=Nothing
    				
    				Set rs3 = Server.CreateObject("ADODB.Recordset") 
             		sql3 = "INSERT INTO log ([autority], [fullname], [username], [email], [timein], [datein], [ip], [host]) VALUES('"&struserautority&"', '"&strname&"', '"&struser&"', '"&stremail&"', '"&strtime&"', '"&strdate&"', '"&strip&"', '"&strhost&"')" 
    				
    				 rs3.open sql3,adoCon
    			'rs3.Close
    		   ' set rs3=Nothing
    			adoCon.Close
    		    set adoCon=Nothing
    				
    			End If
    			
    		End If
    		
    	End If
    	If authorized Then
    		Response.Redirect "restricted_area.asp"
    End If
    
    End If

  4. #4
    ragazzi dai... nessuno mi da una dritta...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.