#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12

    Invalid operation on closed object


    This code is working in my local IIS server, but not working in my website. giving this error:

    ADODB.Recordset.1 error '800a0e78'
    Invalid operation on closed object

    /Adminpages/tableselected.asp, line 72

    I am opening a recordset, and NOT closing it or setting it to Nothing. Anyone have any clue?

    Thanks in advance for your time.

    Code:
    Set MyDB = Server.CreateObject("ADODB.Connection")
    MyDB.Open Session("dbstring") 
    Set MydbSET = Server.CreateObject("ADODB.Recordset")
    MydbSET.ActiveConnection = MyDB
    MydbSET.Source = "Describe " & Session("tblname")
    MydbSET.CursorType = adOpenDynamic
    MydbSET.CursorLocation = 2
    MydbSET.LockType = adLockOptimistic
    MydbSET.Open()
    %>
    <FORM ACTION="insertdata.asp" METHOD="post" TARGET="_self" LANG='<%= Session("lang") %>'>
      <TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="1">
        <TR BGCOLOR="#CCCCCC">
          <TD WIDTH="25%" BGCOLOR="#000000"><FONT COLOR="#CCCCCC"><STRONG> Field</STRONG></FONT></TD>
          <TD WIDTH="32%" BGCOLOR="#000000"><FONT COLOR="#CCCCCC"><STRONG>Insert
                Value</STRONG></FONT></TD>
          <TD WIDTH="20%" BGCOLOR="#000000"><FONT COLOR="#CCCCCC" FACE="Tahoma"><STRONG>Type</STRONG></FONT></TD>
          <TD WIDTH="3%" BGCOLOR="#000000"><FONT COLOR="#CCCCCC"><STRONG>NULL</STRONG></FONT></TD>
          <TD WIDTH="3%" BGCOLOR="#000000"><FONT COLOR="#CCCCCC"><STRONG>Key</STRONG></FONT></TD>
          <TD WIDTH="20%" ALIGN="CENTER" BGCOLOR="#000000"><FONT COLOR="#CCCCCC"><STRONG>Extra</STRONG></FONT></TD>
        </TR>
        <%
    BCOLOR = "#CCCCCC"
    This is line 72 : While not MydbSET.EOF
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    16
    What does your datasource look like? Is it possible that the datasource isn't correct? I'm also curious as you why your dbString is a Session variable. that seems somewhat odd to me. At least the datasource could be correct on your server, but not on the server you upload the code too. In such a case your recordset will never really open, and there the EOF property wouldn't be allowed.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12
    Theres no problem in my datasource. Actually it works when I use Execute command like:

    Set MySET=myDB.Execute("bla bla"). After I set MySET like this my code continues like that:

    While not MySET.EOF
    Do this and Do that
    MySET.MoveNext.
    Wend

    Some HTML

    MySET.MoveFirst
    While not MySET.EOF
    Do some other things
    MySET.MoveNext
    Wend

    Weird thing is, I can do (MoveFirst and use the Set from the beginning) thing for 2~3 times but after that mySET dissapears. And I have to define it again: MySET=MyDB.Execute("bla bla")...

    I cannot use RecordSET, and I have no clue why. Since I can use Execute, it means I have no problem with connecting to database.
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    16
    You can execute:
    "Describe " & session("tblName")

    Just wondering if you are sure you have access to this on the server. Also I'm sure you have an adovbs.inc file included or you would get an error before the one you are getting. Then again it is quite strange because if the query wasn't working then myDBset.eof would simply equate to true not generate an error. Have you tried opening the recordset different ways, just to see if you get it working? Even just the basic:
    set myDBset = server.createObject("ADODB.RECORDSET")
    myDBSet.open "Describe " & session("tblName"), session("dbString")

    just some thoughts
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12
    It is solved!

    As you said in your first reply, I wrote the connection string directly instead of session variable and it worked .

    It is still srange though... I can create a connection object with session variable, but cannot create a recordset with that object...

    The reason I wanted to keep my connection string in a session variable is, this is PhPMyAdmin kinda application and I am using same string in many places...

    Anyway, It is working now and I think I can figure out something else later on... Put it in an .inc file and include in every page maybe...

    Thanks for your time.
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  10. #6
  11. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    If your using the same connection string over and over then you could place it in an Application variable in your global.asa file.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    16
    Do what def jam ninja says and put it in the application in your global.asa file. I DO NOT recommend putting connection strings in .inc files, unlike asp files aren't parsed as asp files, meaning that if someone knows the name of your .inc file they could easily see our connection string just by browswing to the .inc file...i.e. http://yourhomepage.com/allmysecretstuff.inc. As long as they are in the .asa file they are safe cause iis takes measures to protect this file. And as long as your application is running, you can access the application variable.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Shimonoseki / JAPAN
    Posts
    58
    Rep Power
    12
    Actually I was wrong when I said the problem is solved. I somehow forgot to update my pages from object.execute to create recordsets... When I start to use Recordset, problem appeared again. But I think I have found the problem...

    My -not working- recordset commands are "show tables" or "describe tableNAME". When I use "Select * from members" I have created recordset succesfully.

    I think I don't have grant to use "Show" or "Describe" commands, can it be possible?
    Sweet smell of a great sorrow lies over the land. Plumes of smoke rise, merge into the leaden sky. A man lies and dreams of green fields and rivers, but awakes to a morning with no reason for waking. He's haunted by the memory of lost paradise. In his youth or dream, he can't be precise. He's chained forever to a world that's departed. It's not enough, it's not enough.
    Gilmour
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    NJ
    Posts
    428
    Rep Power
    16
    I'm hoping that you are using mySQL. If you are then yes it is possible to grant/deny access to both the show tables command and the describe command. I've never used myODBC, which is what I'm assuming you are using, so i don't know how it works. Do those commands return recordsets? This may be a question you want to ask in the mySQL forum.

IMN logo majestic logo threadwatch logo seochat tools logo