473,327 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Fetch Multiple Records

I am working with VB6 and Access. There is a SQL query I have written to retrieve a few records. But when I try to display these records in a listbox, only the first one is fetched, others are not. What should I do to fetch all??

Expand|Select|Wrap|Line Numbers
  1. Call Connection
  2. Set inv = New ADODB.Recordset
  3.  
  4. inv.Open "SELECT * FROM Invoice_Trans WHERE Inv_No=" & Val(txtInvNo.Text) & "", con, 3, 3
  5.  
  6. lstSrno.AddItem (inv!SrNo)
  7. lstProd.AddItem (inv!Prod_Code)
  8. lstQty.AddItem (inv!Qty)
  9. lstAmt.AddItem (inv!amount)
  10.  
  11. rs.Close
  12.  
Feb 7 '08 #1
4 2660
werks
220 100+
I am working with VB6 and Access. There is a SQL query i have written to retrieve few records. but when i try to display these records in a listbox, only the first one is fetched, others are not. What should i do to fetch all??


Call Connection
Set inv = New ADODB.Recordset

inv.Open "SELECT * FROM Invoice_Trans WHERE Inv_No=" & Val(txtInvNo.Text) & "", con, 3, 3

lstSrno.AddItem (inv!SrNo)
lstProd.AddItem (inv!Prod_Code)
lstQty.AddItem (inv!Qty)
lstAmt.AddItem (inv!amount)

rs.Close

this is my code on viewing records from the DB:

Expand|Select|Wrap|Line Numbers
  1. Dim Ctrlst As Integer
  2. Dim TmpValue As String
  3.  
  4.   While Not adoUser.EOF
  5.         Ctrlst = Ctrlst + 1
  6.             lstLibrarian.ListItems.Add , , adoUser.Fields("BorrowerID")
  7.         For j = 1 To 6     'NUMBER OF COLUMNS IN THE LISTBOX
  8.             TmpValue = ""     'TEMPORARY STORAGE
  9.             If Not adoUser.Fields(j) = "" Then
  10.                 TmpValue = adoUser.Fields(j)
  11.             End If
  12.             lstLibrarian.ListItems(Ctrlst).ListSubItems.Add , , TmpValue
  13.         Next
  14.         adoUser.MoveNext
  15.     Wend
  16.  

Better Than Yesterday ^^
Feb 7 '08 #2
mafaisal
142 100+
Hello,

Try This

Set Item = lvwRoom.ListItems.Add(, , inv!SrNo)
Item.SubItems(1) = inv!Prod_Code
Item.SubItems(2) = inv!Qty

like this

I am working with VB6 and Access. There is a SQL query i have written to retrieve few records. but when i try to display these records in a listbox, only the first one is fetched, others are not. What should i do to fetch all??


Call Connection
Set inv = New ADODB.Recordset

inv.Open "SELECT * FROM Invoice_Trans WHERE Inv_No=" & Val(txtInvNo.Text) & "", con, 3, 3

lstSrno.AddItem (inv!SrNo)
lstProd.AddItem (inv!Prod_Code)
lstQty.AddItem (inv!Qty)
lstAmt.AddItem (inv!amount)

rs.Close
Feb 7 '08 #3
werks
220 100+
try looping it upto the last record...
Feb 7 '08 #4
debasisdas
8,127 Expert 4TB
try like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim sql As String
  3. lstcompany.Clear
  4. sql = "SELECT companyname from company"
  5. RsComp.Open sql, Con, adOpenDynamic, adLockOptimistic
  6. Set lstcompany.DataSource = RsComp
  7.  
  8. For i = 0 To RsComp.RecordCount - 1
  9. lstcompany.AddItem RsComp(0)
  10. RsComp.MoveNext
  11. Next i
  12. RsComp.Close
  13.  
  14.  
  15. End Sub
  16.  
  17.  
Feb 8 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: deebeetwo | last post by:
I am trying to select only a certain number of records from a table. It is easy enough with "fetch first" syntax. What complicates this a bit is the fact that I need to retrieve the number of rows...
4
by: db2admin | last post by:
hi, For the following SQL and plan ============================================================== SELECT Q1.PLCY_KY, Q1.PLCY_TRM_EFCTV_DT, Q1.ACNTG_BGN_DT, CASE WHEN ((Q1.PLCY_SRC_CD = '02')...
4
by: indhu | last post by:
hi all, Tables: story, shot story-fieldnames, project, date episode shot-fieldnames, scene,shot, filename(imagepath),action and dialogue. Form has field from both the tables. how do i fetch...
3
by: nrain | last post by:
Hi This is nrain here in a pl/sql block, some rows are getting inserted into the table violating the primary key and going to exception. I need to fetch records and want to check what...
7
by: Frank Swarbrick | last post by:
Is there a way to do a multi-row fetch in to a COBOL table with DB2/LUW? Apparently the following is supported in z/OS, but not LUW (or at least I couldn't get it to work): WORKING-STORAGE...
3
by: camarun20 | last post by:
Hi , I constructed an MS access query in java to retrieve the rows in random. The code snipet Connection con = DriverManager.getConnection( database ,"",""); Statement s =...
0
by: Rilly | last post by:
Anyone use PowerMovielist here? I have the 0.14 beta version. Do you have a problem where some shows you search for cause the fetch to hang ? I'm pulling my hair out on this.. For example, I search...
0
by: padmaneha | last post by:
Hi Thanks for your response but the query which you gave in my previous post doesnt work. It displays the same cnt for movie reviews and videoreviews Let me explain you in detail As I...
3
Soniad
by: Soniad | last post by:
Hello, In stored procedure, i am using query that fetches 2 columns record but single row. i have used cursor to fetch single record. is there any way to fetch the record and put it in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.