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

RecordSet Lost...

Status
Not open for further replies.

E3

IS-IT--Management
Feb 19, 2002
16
SG
Public Function GetAuctionItemsBySearch(SearchText, PathToPage)
Set Conn = CreateObject("ADODB.Connection")
Conn.ConnectionString = "PROVIDER=SQLOLEDB;DATA SOURCE=" & svrName _
& ";INITIAL CATALOG=" & dbName & ";USER ID=" & userId _
& ";PASSWORD=" & passWd
Conn.Open
Dim RSItems As ADODB.Recordset
Dim TempReturn As String

Set RSItems = Conn.Execute("Select auctionitem_id,productname, " _
& "currentbid,numbid,closingdate from auctionitem " _
& "where productname Like '%" & SearchText & "%' or " _
& "description Like '&" & SearchText & "%'")

TempReturn = &quot;<TABLE BORDER=1 CELLSPACING=3 CELLPADDING=1 WIDTH = 465>&quot; _
& &quot;<TR><TD WIDTH=143><P><B><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich BT &quot;&quot;>Product Name</FONT>&quot; _
& &quot;</B></TD><TD WIDTH=90><P><B><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich BT &quot;&quot;>Current Bid</FONT>&quot; _
& &quot;</B></TD><TD WIDTH=51><P><B><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich BT &quot;&quot;># Bids</FONT>&quot; _
& &quot;</B></TD><TD WIDTH=148><P><B><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich BT &quot;&quot;>Closes</FONT>&quot; _
& &quot;</B></TD></TR>&quot; & vbNewLine
Do Until RSItems.EOF
TempReturn = TempReturn & &quot;<TR>&quot; _
& &quot;<TD WIDTH=143><P><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich BT &quot;&quot;><A HREF=&quot;&quot;&quot; _
& PathToPage & &quot;?AuctionItemID=&quot; & RSItems(&quot;auctionitem_id&quot;) _
& &quot;&quot;&quot;>&quot; & RSItems(&quot;productname&quot;) & &quot;</A></FONT></TD>&quot; _
& &quot;<TD WIDTH=90><P><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich bt &quot;&quot;>&quot; _
& FormatCurrency(RSItems(&quot;currentbid&quot;)) & &quot;</FONT></TD>&quot; _
& &quot;<TD WIDTH= 51><P><FONT SIZE =&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich bt &quot;&quot;>&quot; _
& RSItems(&quot;numbid&quot;) & &quot;</FONT></TD>&quot; _
& &quot;<TD WIDTH= 148><P><FONT SIZE =&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial,Helvetica,Univers,Zurich bt &quot;&quot;>&quot; _
& RSItems(&quot;closingdate&quot;) & &quot;</FONT></TD></TR>&quot; & vbNewLine

RSItems.MoveNext
Loop
TempReturn = TempReturn & &quot;</TABLE>&quot; & vbNewLine
GetAuctionItemsBySearch = TempReturn

End Function

Public Function GetSubCategoriesBySearch(SearchText, PathToPage)
Dim Conn
Dim svrName ' database server name
Dim dbName ' database name
Dim userId ' user id
Dim passWd ' password


'Initialise variables
svrName = &quot;rox-oin2stqk26k&quot;
dbName = &quot;fyp&quot;
userId = &quot;abc&quot;
passWd = &quot;abc&quot;

'Open connection to DB
Set Conn = CreateObject(&quot;ADODB.Connection&quot;)
Conn.ConnectionString = &quot;PROVIDER=SQLOLEDB;DATA SOURCE=&quot; & svrName _
& &quot;;INITIAL CATALOG=&quot; & dbName & &quot;;USER ID=&quot; & userId _
& &quot;;PASSWORD=&quot; & passWd
Conn.Open
Dim RSCategories As ADODB.Recordset
Dim TempReturn As String
Dim RowCount

Set RSCategories = Conn.Execute(&quot;Select cat_name from &quot; _
& &quot;Categories where cat_name = '%&quot; _
& SearchText & &quot;%' Order by cat_name&quot;)
TempReturn = &quot;<TABLE BORDER = 0 CELLSPACING=0 CELLPADDING=2 Width = 120 > &quot; _
& &quot;<TR><TD> WIDTH=116 BGCOLOR =&quot;&quot;#cccc99&quot;&quot;><P ALIGN =CENTRE><B>&quot; _
& &quot;<FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;Arial,Helvetica,Univers,Zurich BT&quot;&quot;>&quot; _
& &quot;Sub Categories</FONT></B></TD></TR>&quot; & vbNewLine
RowCount = 1
Do Until RSCategories.EOF
TempReturn = TempReturn & &quot;<TR>&quot; _
& &quot;<TD WIDTH=116 BGCOlOR=&quot;&quot;#cccc99&quot;&quot;><P><A HREF =&quot;&quot;&quot; _
& PathToPage & &quot;?CategoryName=&quot; & RSCategories(&quot;cat_name&quot;) _
& &quot;&quot;&quot;><B><FONT SIZE=&quot;&quot;-1&quot;&quot; FACE=&quot;&quot;&quot; _
& &quot;Arial Helvetica,Univers,Zurich BT &quot;&quot;>&quot; _
& RSCategories(&quot;cat_name&quot;) & &quot;</FONT></B></A></TD>&quot; _
& &quot;</TR>&quot; & vbNewLine
RSCategories.MoveNext
RowCount = RowCount + 1
Loop
If RowCount < 10 Then
Do Until RowCount = 10
TempReturn = TempReturn & &quot;<TR>&quot; _
& &quot;<TD BGCOLOR=&quot;&quot;#CCCC99&quot;&quot;>&nbsp;</TD>&quot; _
& &quot;</TR>&quot; & vbNewLine
RSCategories.MoveNext
RowCount = RowCount + 1
Loop
End If
TempReturn = TempReturn & &quot;</Table>&quot;
GetSubCategoriesBySearch = TempReturn
End Function



Dim MyAuction
Dim ThePath
Dim TheSubs
Dim TheProducts

Set MyAuction= Server.CreateObject(&quot;Auction.AuctionData&quot;)


If not IsEmpty(Request.Form(&quot;GoSearch&quot;)) Then
ThePath = &quot;&quot;
TheSubs = MyAuction.GetSubCategoriesBySearch(Request.Form(&quot;SearchText&quot;),&quot;./auction_list.asp&quot;)
TheProducts = MyAuction.GetAuctionItemsBySearch(Request.Form(&quot;SearchText&quot;),&quot;./auction_list.asp&quot;)

ElseIf not IsEmpty(Request.Form(&quot;GoBrowse&quot;)) Then
ThePath= MyAuction.GetCategoryPath(Request.Form(&quot;Category&quot;),&quot;./auction_list.asp&quot;)
TheProducts= MyAuction.GetAuctionItemsByCategory(Request.Form(&quot;Category&quot;),&quot;./auction_list.asp&quot;)

Elseif not IsEmpty(Request.QueryString(&quot;CategoryName&quot;)) Then
ThePath = MyAuction.GetCategoryPath(Request.QueryString(&quot;CategoryName&quot;),&quot;./auction_list.asp&quot;)
TheSubs = MyAuction.GetSubCategories(Request.QueryString(&quot;CategoryName&quot;),&quot;./auction_list.asp&quot;)
TheProducts = MyAuction.GetAuctionItemsByCategory(Request.QueryString(&quot;CategoryName&quot;),&quot;./auctionitem.asp&quot;)

Else
Response.Redirect &quot;./auction_menu.asp&quot;

End If


The first file is component I ve created using VB. In it are similiar methods/functions. For method, i have a new connection to DB. The second asp file is calling a method from the component. I checked and checked but I have this recordset error??????????? This error is quite new to me and I can't quite solve my current problem

Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/Auction_List.asp, line 14


Any idea on whats wrong with it??




:confused: :confused: :mad:
 
I found a mistake in the sql statement I written
should be Like instead of an equal sign.

Somehow I m still having problems with the recordset and can't display the results
 
I might have overlooked it, but where are you Response.Write-ing the return values?

leo

------------
Leo Mendoza
lmendoza@garbersoft.net
 
I have it in the later part of my asp file in the main html body codes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top