Forum Moderators: open
When trying to post a reply, members are getting this error:
************************************
Microsoft VBScript runtime error '800a01a8'
Object required: 'conn'
/include/sitetools.asp, line 19
************************************
Here is the sitetools code:
<%
'Database Connectivity
Function OpenConnection
set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "****", "***", "****"
'conn.open "Provider=MSDASQL;Driver={SQL Server};Server=********;Database=******;" &_
'"UID=****;PWD=*****;"
End Function
Function OpenUnlimitedConnection
set conn = Server.CreateObject("ADODB.Connection")
conn.connectiontimeout = 0
Conn.Open "*****", "****", "****"
End Function
Function CloseConnection
conn.close <-----------------LINE 19
set conn=nothing
End Function
___________________________________________________
Here is where that function is being called:
<%'Display Text from Post
if Request.QueryString("method") = "reply" then
OpenConnection()
sql = "Select T_Message from Topics where topic_id = " & Request.QueryString("topic_id")
RecordsetOpen(sql)
If not rs.eof then
t_message = formatstr(rs("t_message"))
%>
<table border="0" Width=500>
<tr bgcolor="#cccccc">
<td noWrap align=center><font face="<% =DefaultFontFace %>" size="1">
<STRONG>Original Topic Text</STRONG></td></tr>
<tr bgcolor="#cccccc">
<td><font face="<% =DefaultFontFace %>" size="1">
<%response.write t_message%>
</td></tr>
</table>
<%End If
RecordsetClose()
CloseConnection()
End If
%>
Thanks in advance for your help. When giving me advice, please imagine you are talking to your grandparents :) Or somebody else completely technologically challenged.
This error causes no problems, members are able to post...but they are complaining about the error message just the same.
THANK YOU!
Function CloseConnection(byref connDb)
connDb.close
set conn=nothing
End Function<%CloseConnection(conn)%>
If that fails, change it back and add the following line to the top of your page (outside any function)
Dim conn
>This error causes no problems
I wouldn't be so sure about that. If you're not closing your connections properly you'll be suffereing a performance hit.
Public Sub OpenConnection ()
Set conn = CreateObject("ADODB.Connection")
Conn.Open "****", "***", "****"
End Sub
Public Sub OpenUnlimitedConnection()
set conn = CreateObject("ADODB.Connection")
conn.connectiontimeout = 0
Conn.Open "*****", "****", "****"
End Sub
Public Sub CloseConnection()
if conn.state = adStateOpen Then
conn.close()
end if
set conn=nothing
End Sub