|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Weird behavior with Dictionary Object
Hi folks.
Apparently there is something important about using the Dictionary object that I don't understand, and it's driving me up the wall. I'm opening a recordset and reading from a MySQL database, with a query like this: strSQL = "SELECT country,timezone FROM " & oTablename & " WHERE receipt LIKE '%" & oReceipt & "%'"Then the values returned are stored to a dictionary object like so: Session("MemberRecord").Add "country", RS.fields("country")Then the database cleanup: RS.closeFor troubleshooting I inserted the following two lines: Response.write "RS.fields('country') = " & RS.fields("country") & "<br>"Now the problem: Both of the Response.Writes display the correct value IF those two lines are placed BEFORE the database cleanup. If placed after the database cleanup, the attempt to write the RS.fields value fails as is to be expected. However, what I can't explain is why printing of the dictionary element also fails at this point. All it returns is: error '80020009'Where line 160 is the Response.Write. Surely the contents of the elements of the dictionary object shouldn't be dependent on keeping open the database that its values came from! And I haven't had any success trying to fathom a reason from that error number. Can someone PLEASE throw some light on this behavior. TIA |
|
#2
|
||||
|
||||
|
try w/o .add
Code:
If Len(sTableName) > 0 AND Len(sReceipt) > 0 Then
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("database.mdb") & ";"
Set oRs = oConn.Execute("SELECT country,timezone FROM " & sTablename & " " & _
"WHERE receipt = '" & sReceipt & "';")
If Not oRs.EOF Then
sCountry = oRs("country")
sTimeZone = oRs("timezone")
oRs.Close
Set oRs = nothing
oConn.Close
Set oConn = nothing
Set Session("MemberRecord") = Server.CreateObject("Scripting.Dictionary")
Session("MemberRecord")("country") = sCountry
Session("MemberRecord")("timezone") = sTimeZone
End If
End If
%>
__________________
Please give respect to those that helped solve an issue by clicking on the reputation icon
|
|
#3
|
|||
|
|||
|
I gave up on the dictionary object and took a different approach, as it was taking too long to sort out.
However I'll revisit this in a couple of days and try your suggestion. So is there a known problem with .Add ??? TIA |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Weird behavior with Dictionary Object |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|