Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Problem in Getting Records from Database
Old 09-14-2005, 06:01 AM Problem in Getting Records from Database
faisalzafar's Avatar
Experienced Talker

Posts: 41
Location: Pakistan
Trades: 0
Hi to all,

I have some problem plz see that and tell me if u found any fault

when i run this script i found the error of "Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."


and the Code

<%
Dim i,sql,masID
sql = "Select * From Products Where Ishotpick='1' "
Set rs = server.CreateObject ("ADODB.Recordset")
rs.Open sql,cn,2
%>
<tr>
<%
Do While Not rs.EOF
%>
<%
Dim sql11
sql11 = "Select * From ProductAttributes Where ProductID="&rs("ProductID")
response.Write(sql11) // When we Print this query its running fine
Set rs11 = server.CreateObject ("ADODB.Recordset")
rs11.Open sql11,cn,2
if rs11.eof then
response.Write "Empty"
else
response.Write "Some Data Found" // this line execute (means data found)
end if
response.Write rs11("ProductID") // if i want to print this valid varibale value then error occure
%>
<%
rs.MoveNext()
if rs.EOF then
Exit Do
End if
Loop
%>
__________________
[COLOR=Pink]Faisal Zafar[/COLOR]
faisalzafar is offline
Reply With Quote
View Public Profile Visit faisalzafar's homepage!
 
 
Register now for full access!
Old 09-14-2005, 05:14 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
and which line does it error out on ?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-28-2005, 10:20 PM
The Dorian's Avatar
Skilled Talker

Posts: 74
Location: Orange County, California
Trades: 0
I think you're using the wrong recordset to spit out your productID. Change the line

response.Write rs11("ProductID") // if i want to print this valid varibale value then error occure

to

response.Write rs("ProductID") // if i want to print this valid varibale value then error occure

Let me know if that fixes the problem.
__________________
Dorian Collier

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
The Dorian is offline
Reply With Quote
View Public Profile Visit The Dorian's homepage!
 
Old 09-28-2005, 11:26 PM
ExpressoDan's Avatar
Ultra Talker

Posts: 317
Name: This Space for Rent
Location: Georgia
Trades: 0
This line doesnt look right either:
if rs11.eof then

Should be
if sql11.eof then
???
Right

Dan
ExpressoDan is offline
Reply With Quote
View Public Profile Visit ExpressoDan's homepage!
 
Old 09-29-2005, 01:37 PM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
Quote:
This line doesnt look right either:
if rs11.eof then

Should be
if sql11.eof then
???
Right
No - sql11 is a string variable simply containing the SQL Statement.
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 09-29-2005, 02:09 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
Try changing this:
if rs11.eof then

to this
if rs11.bof and rs11.eof then
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 09-29-2005, 06:24 PM
robsmith's Avatar
Skilled Talker

Posts: 50
Location: UK
Trades: 0
If there is key relationship between both tables, you should use sql's INNER JOIN, which will return the results for both tables in one recordset, like this:

SELECT products.*,ProductAttributes.* FROM products INNER JOIN ProductAttributes ON products.productID = ProductAttributes.productID WHERE Ishotpick='1'



And you dont need the If statement if you remove the Do...Loop and replace it with While....wend, , ie.

while (not rs.EOF)

...stuff....

Rs.movenext
Wend
robsmith is offline
Reply With Quote
View Public Profile
 
Old 10-03-2005, 06:52 PM
WebcyteDesign's Avatar
Registered User

Posts: 159
Location: Hamilton
Trades: 0
you've check for rs11.eof but you still put response.Write rs11("ProductID") outside of that check. If there is no info to show you will get an error. Also try rs11.movefirst and then iterate through your records. Also I don't see why

if rs.EOF then
Exit Do
End if

that is needed. You've already checked for this condition at the beginning of the loop.
WebcyteDesign is offline
Reply With Quote
View Public Profile Visit WebcyteDesign's homepage!
 
Reply     « Reply to Problem in Getting Records from Database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39677 seconds with 12 queries