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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database ConnectionS

Status
Not open for further replies.

cumap

IS-IT--Management
Joined
Jul 9, 2007
Messages
268
Location
US
Hi all,

I'm having this question about why one set of code works
Code:
set cn=Server.CreateObject("ADODB.Connection")
cn.Provider="Microsoft.Jet.OLEDB.4.0"
cn.Open(Server.Mappath("data/inventory.mdb"))
On Error resume Next
if err.number <> 0 then
	response.write "Error Number: " & err.number & "<BR>"
	response.write "Error Description: " & err.description
end if
on error goto 0
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select subCatName FROM products WHERE mainCatName = 'Badminton'", cn
while another way
Code:
cnStr = "Provide=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("data/inventory.mdb")
On Error resume Next
Set cn = Server.CreateObject("ADODB.Connection")
cn.open cnStr
if err.number <> 0 then
	response.write "Error Number: " & err.number & "<BR>"
	response.write "Error Description: " & err.description
end if
on error goto 0
sql = "Select subCatName FROM inventory WHERE mainCatName = 'Badminton'"
set rs = cn.execute(sql)
If not rs.eof then
	Response.write "Badminton:<BR>"
	Do while not rs.eof
		Response.write rs("subCatName")
		rs.movenext
	Loop	
End If
rs.close
set rs = nothing
cn.close
set cn = nothing
keeps telling me error likes
ADODB.Connection (0x800A0E78)
Operation is not allowed when the object is closed.

they both seems to do the same thing, don't they?

thanks!
 
In the second one your connection string starts:

"Provide="

rather than

"Provider="

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top