Click to See Complete Forum and Search --> : What is wrong with this Query???


shanuragu
06-18-2003, 08:14 AM
Hi

What is wrong with the following sql operations

Set Con = Server.CreateObject("adodb.connection")
Set RsCdPrice = Server.CreateObject("adodb.recordset")
Con.open "lila"

cost=0
shipchrg=0
For i=0 To UBound(a)
'strsql = "SELECT cp.*, ct.* from CdPrice cp, CdTitles ct Where cp.CdTitleId=ct.CdTitleId And cp.CountryId="&ConId&" And cp.CdTitleId="&a(i)&""
strsql = "Select cp.*, ct.*" & _
" FROM CdPrice as cp, CdTitles as ct" & _
" WHERE ((cp.CdTitleId=ct.CdTitleId)" & _
" And cp.CountryId="&ConId&" And cp.CdTitleId="&a(i)&")"


Response.write("query" & strsql & "<br>")

RsCdPrice.Open strsql, Con,adlockoptimistic,, adCmdText
Next

I am getting the following error,

Error Type:
ADODB.Recordset (0x800A0E79)
Operation is not allowed when the object is open.
/lila/asp/orderdetails.asp, line 81


What could be the reason???
Please help:confused: :(

ShaRa

shanuragu
06-18-2003, 09:49 AM
It is a commented one.

ShaRa

shanuragu
06-18-2003, 10:35 PM
here the code with close before next open

For i=0 To UBound(a)
strsql = "Select cp.*, ct.*" & _
" FROM CdPrice as cp, CdTitles as ct" & _
" WHERE ((cp.CdTitleId=ct.CdTitleId)" & _
" And cp.CountryId="&ConId&" And cp.CdTitleId="&a(i)&")"
Response.write("query" & strsql & "<br>")
'Set RsCdPrice=Con.Execute(strsql)
RsCdPrice.Open strsql, Con,adlockoptimistic,, adCmdText
RsCdPrice.Close
Next

Here is the error for the above code

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.

shanuragu
06-19-2003, 05:24 AM
It's working great.

Thank you again!!:D