Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP Session again

ASP Session again

Scheduled Pinned Locked Moved Web Development
javascriptsysadminhelpquestionlearning
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BlackRider
    wrote on last edited by
    #1

    Hello, I've got the following code test.asp <%@ language="Javascript" %> <% var Connection,Recordset; Connection = Server.CreateObject("ADODB.Connection"); Connection.Open("thesourcename"); var strSQLQuery = "SELECT * FROM clients WHERE .... " Recordset = Connection.Execute(strSQLQuery); Session("test") = Recordset.Fields("user_name"); Response.Redirect("test1.asp"); %> and I've got another code ... test1.asp <%@ language="Javascript" %> <% Response.Write(Session("test")); %> Someone PLEASE tell me what am I doing WROOOOOOOOONG bacause ASP is driving me crazy. The book sais that the Session object should store the values from page to page. I get an ADODB.Field no longer available error message. Could someone please tell me why ????????????????? I've got almost the same code in VBScript and it works .... WHAT'S WRONG ?? Thank you !

    P P 2 Replies Last reply
    0
    • B BlackRider

      Hello, I've got the following code test.asp <%@ language="Javascript" %> <% var Connection,Recordset; Connection = Server.CreateObject("ADODB.Connection"); Connection.Open("thesourcename"); var strSQLQuery = "SELECT * FROM clients WHERE .... " Recordset = Connection.Execute(strSQLQuery); Session("test") = Recordset.Fields("user_name"); Response.Redirect("test1.asp"); %> and I've got another code ... test1.asp <%@ language="Javascript" %> <% Response.Write(Session("test")); %> Someone PLEASE tell me what am I doing WROOOOOOOOONG bacause ASP is driving me crazy. The book sais that the Session object should store the values from page to page. I get an ADODB.Field no longer available error message. Could someone please tell me why ????????????????? I've got almost the same code in VBScript and it works .... WHAT'S WRONG ?? Thank you !

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      Apologies for not answering your actual question but don't do what you are doing. You are leaving connection objects to the database open, redirecting to other pages without closing them. That is not good. Maybe explain what you want to do and we can recommend some better ways of doing it. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

      B 1 Reply Last reply
      0
      • P Paul Watson

        Apologies for not answering your actual question but don't do what you are doing. You are leaving connection objects to the database open, redirecting to other pages without closing them. That is not good. Maybe explain what you want to do and we can recommend some better ways of doing it. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

        B Offline
        B Offline
        BlackRider
        wrote on last edited by
        #3

        Don't mind the fact that I'm not closing the recordset and the connection. In real life I do that ... :) The problem is that I want the test1.asp script to display the content of the Session("UserName") but I am not succesful because I get an error saying that : Error Type: ADODB.Field (0x80020009) Object is no longer valid. /meteo/test1.asp, line 3 Here is the code: test.asp <%@ language="Javascript" %> <% var Connection,Recordset; Connection = Server.CreateObject("ADODB.Connection"); Recordset = Server.CreateObject("ADODB.Recordset"); Connection.Open("Clienti"); var strSQLQuery = "SELECT * FROM clienti WHERE nume_utilizator = \'" + "radio" +"\'"; Recordset=Connection.Execute(strSQLQuery); Session("UserName") = Recordset.Fields("nume_utilizator"); Recordset.Close(); Connection.Close(); Response.Redirect("test1.asp"); %> and test1.asp <%@ language="Javascript" %> <% Response.Write(Session("UserName")); %>

        P 1 Reply Last reply
        0
        • B BlackRider

          Don't mind the fact that I'm not closing the recordset and the connection. In real life I do that ... :) The problem is that I want the test1.asp script to display the content of the Session("UserName") but I am not succesful because I get an error saying that : Error Type: ADODB.Field (0x80020009) Object is no longer valid. /meteo/test1.asp, line 3 Here is the code: test.asp <%@ language="Javascript" %> <% var Connection,Recordset; Connection = Server.CreateObject("ADODB.Connection"); Recordset = Server.CreateObject("ADODB.Recordset"); Connection.Open("Clienti"); var strSQLQuery = "SELECT * FROM clienti WHERE nume_utilizator = \'" + "radio" +"\'"; Recordset=Connection.Execute(strSQLQuery); Session("UserName") = Recordset.Fields("nume_utilizator"); Recordset.Close(); Connection.Close(); Response.Redirect("test1.asp"); %> and test1.asp <%@ language="Javascript" %> <% Response.Write(Session("UserName")); %>

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          Ok, my ASP is a bit rusty but I think the problem is because you are storing the object itself, not the value. Because you close the connection, the object becomes invalid. Damn, JScript needs a ToString() method :-D David Wulff, a JScript genius, says you should use Session("UserName") = String(Recordset.Fields("nume_utilizator"));. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

          B 1 Reply Last reply
          0
          • P Paul Watson

            Ok, my ASP is a bit rusty but I think the problem is because you are storing the object itself, not the value. Because you close the connection, the object becomes invalid. Damn, JScript needs a ToString() method :-D David Wulff, a JScript genius, says you should use Session("UserName") = String(Recordset.Fields("nume_utilizator"));. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

            B Offline
            B Offline
            BlackRider
            wrote on last edited by
            #5

            Seems to be working (for now) ... thank you !

            1 Reply Last reply
            0
            • B BlackRider

              Hello, I've got the following code test.asp <%@ language="Javascript" %> <% var Connection,Recordset; Connection = Server.CreateObject("ADODB.Connection"); Connection.Open("thesourcename"); var strSQLQuery = "SELECT * FROM clients WHERE .... " Recordset = Connection.Execute(strSQLQuery); Session("test") = Recordset.Fields("user_name"); Response.Redirect("test1.asp"); %> and I've got another code ... test1.asp <%@ language="Javascript" %> <% Response.Write(Session("test")); %> Someone PLEASE tell me what am I doing WROOOOOOOOONG bacause ASP is driving me crazy. The book sais that the Session object should store the values from page to page. I get an ADODB.Field no longer available error message. Could someone please tell me why ????????????????? I've got almost the same code in VBScript and it works .... WHAT'S WRONG ?? Thank you !

              P Offline
              P Offline
              Populate123
              wrote on last edited by
              #6

              Use the below <% @LANGUAGE = VBScript%> This will also help you to get rid from unimportant error. And be COOL. Himadrish Laha

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups