|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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. ![]() |
|
#6
|
|||
|
|||
|
If your using the same connection string over and over then you could place it in an Application variable in your global.asa file.
|
|
#7
|
|||
|
|||
|
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.
|
|
#8
|
|||
|
|||
|
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? |
|
#9
|
|||
|
|||
|
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.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Invalid operation on closed object |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|