Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Global.ASA

  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Exclamation Global.ASA

    i got problem with setting the connection to the db on the global.asa.
    fiirst i added includes but the error told me that i must not us%><% in global .asa...than wrote all the connection string lines inside the file but still it not working


    Code:
    
    <script language="vbscript" runat="server">
    
    
    
    
      
    
    dim pDatabaseConnectionString, pSupportErrorEmailFrom, pSupportErrorSMTP, pSupportErrorEmailComponent, pSupportErrorShowDetails, pTrapDbErrors, pIdStore
    
    private const pDataBase			= "mysql"
    
    pDatabaseConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=mySQL42.domain.com;database=user;user=user;password=password;OPTION=x"                        
    
    
    sub openDb()
     if varType(connTemp)=0 or varType(connTemp)=1 then   
     
       ' create the connection
       set connTemp	= server.createObject("adodb.connection")      
        
       connTemp.Open pDatabaseConnectionString
     
       if err.number <> 0 then
         response.redirect "supportError.asp?error="&Server.Urlencode("Error while opening DB read:"&Err.Description& "<br><br><b>Common solutions</b><br><br>1. Check that you haven't change default database path and name <br>2. Check that your web server has Access 97 or 2000 ODBC installed <br>3. Check that you have read, modify and delete permissions over database folder and database file  <br>4. Open your database with Access program and select Repair Database option <br>5. Select other connection method like other connection string or DSN")    
       end if
      
     end if 
    end sub
    
    sub updateDatabase(mySQL, rsTemp, scriptName) 
      
     call openDb()    
       
     set rsTemp=connTemp.execute(mySQL)
     
     if err.number <> 0 then  
       response.redirect "supportError.asp?error="&Server.Urlencode("Update Error in " &scriptName& ", error: "&Err.Description& " - Err.Number:"&Err.number&" - SQL:"&mySQL)          
     end if
      
    end sub
    
    
    function closeDB()
      on error resume next
      
      rsTemp.close
      set rsTemp 		= nothing 
      connTemp.close
      set connTemp	 	= nothing
     
    end function
    
    
    
    
    
    
    Sub Application_OnStart
    	Application("active_visitors")=0
    End Sub
    
    
    Sub Session_OnStart
    Application.Lock
    Application("active_visitors")=Application("active_visitors")+1
    Application.UnLock
    
    if Session("usernameid")<>"" then
    dim vab, mySQL, conntemp, rstemp
    vab=Session("usernameid")
    mySQL="UPDATE crmagents SET online=1 WHERE online='" & vab & "'"
    call updateDatabase(mySQL, rstemp, "mohdiomexe.asp")
    end if
    
    end sub
    
    
    
    
    
    Sub Session_OnEnd
    Application.Lock
    Application("active_visitors")=Application("active_visitors")-1
    
    dim vab, mySQL, conntemp, rstemp
    vab=Session("usernameid")
    mySQL="UPDATE crmagents SET online=0 WHERE online='" & vab & "'"
    call updateDatabase(mySQL, rstemp, "mohdiomexe.asp")
    
    Application.UnLock
    end sub
    
    
    
    
    sub Application_OnEnd
    end sub
    
    
    
    call closeDb()
    
    
    
    </script>
    By the time u recognize this moment, This moment will be gone.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Unhappy another idea i got...but still not working

    Code:
    <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
    Sub Application_OnStart
        Application.Lock
            Application("Active") = 0
        Application.Unlock
    End Sub
    
    Sub Session_OnStart
    
    dim vab, mySQL, conexion, RS
        Set conexion = Server.CreateObject("ADODB.Connection")
        Set RS = Server.CreateObject("ADODB.Recordset")
        conexion.Open "Driver={MySQL ODBC 3.51 Driver};Server=mySQL42.domain.com;database=user;user=user;password=pass;OPTION=x"
        
    
    
    
    
    vab=Session("usernameid")
    
        mySQL="Select * From crmagents WHERE online='" & vab & "'"
        rs.open mySQL, conexion,2,3,1
        
        
        If rs.EOF Then   
        rs("online") = Now() 
        rs.Update
        end if
    
        Application.lock()
            Application("NumVisitas") = Application("NumVisitas") + 1
        Application.unlock()
        
        rs.close
            
    End Sub
    
    Sub Session_OnEnd
        mySQL="Select * From crmagents WHERE online='" & vab & "'"
        rs.open mySQL, conexion,2,3,1
    
    
        rs("online") = ""
    
        rs.Update
        rs.close
        
         Application.lock()
             Application("NumSesion") = Application("NumSesion") - 1
         Application.unlock()
    End Sub
    
    
    
    
    </script>
    By the time u recognize this moment, This moment will be gone.

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Posts
    179
    Thanks
    4
    Thanked 0 Times in 0 Posts

    that is the old mdb access version i had before

    Code:
    <script language="VBScript" runat="Server">
    
    Sub Session_OnStart
    
    Application.Lock
    Application("active_visitors")=Application("active_visitors")+1
    Application.UnLock
    
    
    dim conn, rs
    Set conn	= Server.CreateObject("ADODB.Connection")
    ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" &	_
    "Data Source=\\premfs16\sites\premium16\enter\database\db1.mdb;"
    Conn.Open ConnString
    
    set rs=Server.CreateObject("ADODB.recordset")
    
    if	Session("USERNAME")<>""	then
    	rs.Open "Members where Username='" & Session("USERNAME")	& "'", Conn, 2, 3
    	rs("Online")=1
    	rs.Update
    	rs.Close
    	set rs =	nothing
    end if
    
    conn.Close
    set conn=nothing
    
    End Sub
    
    
    
    Sub Session_OnEnd
    Application.Lock
    Application("active_visitors")=Application("active_visitors")-1
    
    dim conn, rs
    Set conn	= Server.CreateObject("ADODB.Connection")
    ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" &	_
    "Data	Source=\\premfs16\sites\premium16\enter\database\db1.mdb;"
    
    Conn.Open ConnString
    set rs=Server.CreateObject("ADODB.recordset")
    rs.Open "Members where Username='" & Session("USERNAME")	& "'", Conn, 2, 3
    rs("Online")=0
    rs.Update
    rs.Close
    set rs =	nothing
    conn.Close
    set conn=nothing
    Application.UnLock
    end sub
    
    
    Sub Application_OnStart
    	Application("active_visitors")=0
    End Sub
    
    
    sub Application_OnEnd
    
    end sub
    
    
    </SCRIPT>
    By the time u recognize this moment, This moment will be gone.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •