none
Query to read number of records in Access table

    Question

  • I would like to know the correct syntax for a query to read the number of records in an Access table and store the number in a variable

    Chandrasekharan Kunnath

    Wednesday, October 05, 2016 12:29 PM

Answers

  • Hi Kunnath Chandrasekharan,

    Which development language do you use?

    Please try with the OledbConnection class to connect to your Access data source and query the records count with "Select COUNT(*) from TableName".

    If any questions, please feel free to let me know.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 12, 2016 1:18 AM
    Moderator

All replies

  • E.g.

    Dim RowCount As Long
    RowCount = DCount("*", "YourTableName")

    Wednesday, October 05, 2016 12:59 PM
  • Hi Kunnath Chandrasekharan,

    Which development language do you use?

    If you are using VB, please refer to Stefan Hoffmann's suggestion.

    If you are using C#, please try with following code.

    using (OledbConnection cn = new OledbConnection())
     {
                    cn.ConnectionString = OledbConnectionString;
                    cn.Open();
    
                    OledbCommand commandRowCount = new OledbCommand("SELECT COUNT(*) FROM [TABLENAME]", cn);
     }

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 06, 2016 5:42 AM
    Moderator
  • I am afraid the DCount function does not work in Visual Studio

    Chandrasekharan Kunnath

    Tuesday, October 11, 2016 12:14 PM
  • Hi Kunnath Chandrasekharan,

    Which development language do you use?

    Please try with the OledbConnection class to connect to your Access data source and query the records count with "Select COUNT(*) from TableName".

    If any questions, please feel free to let me know.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 12, 2016 1:18 AM
    Moderator
  • Thank you.

    Chandrasekharan Kunnath

    Wednesday, October 12, 2016 2:21 AM
  • Hi Kunnath Chandrasekharan,,

    If the "Select COUNT(*) from TableName" works for you, please mark the helpful reply as answer, which is benefit to other communities who has the same issue.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 12, 2016 2:51 AM
    Moderator