Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP and Database Connection Question 1

Status
Not open for further replies.

Manxman55

IS-IT--Management
Aug 16, 2005
5
GB
OK Guys,

I got the database open with the following code (which all works perfectly)....

// Build the sql statement
m_strSQL = "select * from <datatable> where Remote_IP Like '%" & Request.ServerVariables("REMOTE_ADDR") & "%';"
// Create the MySQL Connection.
set MySQLConn = server.createobject("adodb.connection")
// Open the Database
MySQLConn.open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=<IP Address>;DATABASE=(Database Name>;USER=<User Name>;PASSWORD=<Password>;OPTION=3;"
// Open recordset
Set objRS = MySQLConn.Execute(m_strSQL)
//
If objRS.EOF Then Response.Redirect("ID_Survey.asp")
//
%>

Silly question is, having directed the browser to another page, (or stayed on this one depending on the "objRS.EOF" result) how do I close the Database and Connection?

 
here...something like this:
Code:
If objRS.EOF AND objRs.EOF Then 
'Now close all your objects
set rs=Nothing
rs.close
set con=Nothing
con.close
Response.Redirect("ID_Survey.asp")
else
'display your records
Do until objRS.EOF 
'display fields
objRS.Movenext
Loop
'Now close all your objects
set rs=Nothing
rs.close
set con=Nothing
con.close
end if

-DNG
 
oops change variables rs and con to reflect your own recordset object and connection object.

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top