Hi all,
I'm having this question about why one set of code works
while another way
keeps telling me error likes
they both seems to do the same thing, don't they?
thanks!
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
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
ADODB.Connection (0x800A0E78)
Operation is not allowed when the object is closed.
they both seems to do the same thing, don't they?
thanks!