Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

how to know the number of record in vb

Last post 03-25-2008 4:20 PM by oshin. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 03-20-2008 2:00 PM

    • oshin
    • Not Ranked
    • Joined on 03-20-2008
    • Malaysia
    • New Member
    • Points 45

    how to know the number of record in vb

    Hi, how can i display the number of same record. For example i have record with customer no. 2444 and there's a lot of record for this customer. how can i show that the customer have a lot of records. for example "There is 24 record for customer 2444 ". Thanks

    • Post Points: 10
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 03-25-2008 10:38 AM In reply to

    • Jugatsu
    • Top 500 Contributor
    • Joined on 02-15-2006
    • Member
    • Points 380

    Re: how to know the number of record in vb

    You can do a count of the records in the database

    Execute the following SQL and it will return the count.

    SELECT count(*) FROM Your_TABLE WHERE customerNumber='2444'

     

    • Post Points: 10
  • 03-25-2008 11:10 AM In reply to

    • oshin
    • Not Ranked
    • Joined on 03-20-2008
    • Malaysia
    • New Member
    • Points 45

    Re: how to know the number of record in vb

    well im using Access database in vb and im hoping that u can teach me how to do so in vb 6, where if i put 2444 in text box for searching that customer and i want it to display the number of records in label...
    • Post Points: 10
  • 03-25-2008 11:36 AM In reply to

    • oshin
    • Not Ranked
    • Joined on 03-20-2008
    • Malaysia
    • New Member
    • Points 45

    Re: how to know the number of record in vb

     well im using Access database in vb and im hoping that u can teach me how to do so in vb 6, where if i put 2444 in text box for searching that customer and i want it to display the number of records in label...

    • Post Points: 5
  • 03-25-2008 11:52 AM In reply to

    • Jugatsu
    • Top 500 Contributor
    • Joined on 02-15-2006
    • Member
    • Points 380

    Re: how to know the number of record in vb

    Using DAO ( add a reference to Microsoft DAO...) 

         Dim db As Database
        Dim rs As DAO.Recordset
        Set db = OpenDatabase("c:\mydatabase.mdb")
        Set rs = db.OpenRecordset("SELECT count(*) FROM Your_TABLE WHERE customerNumber=" & Text1.Text)
        rs.MoveFirst
        Label1.Caption = rs.Fields(0) & " records for customerNumber : " & Text1.Text
        Set rs = Nothing
        Set db = Nothing

     

    • Post Points: 10
  • 03-25-2008 12:19 PM In reply to

    • oshin
    • Not Ranked
    • Joined on 03-20-2008
    • Malaysia
    • New Member
    • Points 45

    Re: how to know the number of record in vb

    is there any other way to do it without using sql..i don't really know sql and i use data control to connect access to vb.. 

    • Post Points: 10
  • 03-25-2008 1:04 PM In reply to

    • Jugatsu
    • Top 500 Contributor
    • Joined on 02-15-2006
    • Member
    • Points 380

    Re: how to know the number of record in vb

    There are many ways to do something like this, you never specified how you were connecting to the database.

    Try 

     Data1.RecordSource = "SELECT *  FROM Your_TABLE WHERE Your_TABLE.customerNumber = " & Text1.Text
     Data1.Refresh
     Data1.Recordset.MoveLast
     Label1.Caption = Data1.Recordset.RecordCount

     ** Change the Your_TABLE to the name of your table & customerNumber to the name of the field

    • Post Points: 10
  • 03-25-2008 4:20 PM In reply to

    • oshin
    • Not Ranked
    • Joined on 03-20-2008
    • Malaysia
    • New Member
    • Points 45

    Re: how to know the number of record in vb

    oh..sorry about that..i'm using usejet to connect to the database..so is there anyway
    • Post Points: 5
Page 1 of 1 (8 items)