Reputation: 51
This is driving my crazy. I get an error ("500 - Internal server error.") on my web page when returning from this sub. It executes just fine and does what it's supposed to do: add a record of a user (MemID) to the Chat table for an event (EventID) if it hasn't already been added. The first query is to find out if there's already a record. If not, the INSERT statement adds a record. The error occurs after the sub has run.
Sub NewView (EventID)
MemID=Session("MemID")
If MemID>0 then
Set cn5=Server.CreateObject("ADODB.connection")
cn5.open application("gbConnect")
SQL="SELECT Chat.MemID, Chat.EventID FROM Chat WHERE Chat.MemID=" & MemID & " AND Chat.EventID=" & EventID & ";"
cn5.cursorLocation=3
Set Rst=cn5.execute(SQL)
If Rst.recordcount = 0 then
Comment="is watching"
SQL="INSERT INTO Chat ( MemID, EventID, Comment ) SELECT " & MemID & "," & EventID & ", '" & Comment & "';"
cn5.execute(SQL)
Set cn5=nothing
End If
End If
End Sub
On the page: NewView (EventID) 'Returning from this sub causes an error! "500 - Internal server error."
Upvotes: 1
Views: 90
Reputation: 51
OK. I figured it out. I got a lesson in scope of variables. Setting the variable Rst (recordset) in the sub ruined the same variable on the main page. Now just have to wait for my hair to grow back.
Upvotes: 1