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

Database ConnectionS 1

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
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)
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!

p.s. I hope you wouldn't mind when finding this same question of mine in Access Queries forum.
 
Looks like a typo: [tt]
Provide[red]r[/red][/tt]
 
GOOD EYE!!!

Thank you very much!!! And here I thought there is different ways for different particular database system.

hehehe!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top