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

getrows

Status
Not open for further replies.

parames

MIS
Jun 26, 2000
71
MY
hi list..really need your help...

I wanted to select 10 recently added product_code to be displayed out.

Query = "select no,product_code from fg_lcb order by no desc"
Set RS=Conn.Execute(Query)
alldata = RS.GetRows()

numcols=ubound(alldata,1)
numrows=ubound(alldata,2)

FOR rowcounter= 0 TO numrows
FOR colcounter=0 to numcols
....
....
NEXT
NEXT

scenerio:
1)no is a key and product_code is the product
2)The query returns more than 20000 records and has more than 1 same product_code
3)what i wanted to do is,
a) for each row, select the no and product_code, put in an array.(for first record)
b) Then, the next following rows, compare the product_code with the product_code inside the array.
c) if the product_code is same, then skip. Else, add to the array
d)do this until i get 10 product_code.

I have no idea on how to do this..Please do guide me..

If there is any other solution..please do tell me..

thanks a lot..

best Regards,
Parames.S

 
Query = "select no,product_code from fg_lcb order by no desc"
Set RS=Conn.Execute(Query)

dim varArray(1,9)
dim inArray, i, lastRow, count : count = 0

do while not RS.Eof

inArray = false
for i = 0 to count
if varArray(1,i) = RS("product_code") then
inArray = true
exit for
end if
next

if not inArray then
varArray(0,count) = RS("no")
varArray(1,count) = RS("product_code")
count = count + 1
end if

if count = 10 then exit do

RS.MoveNext

loop

RS.close
Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top