What is the counter part of recordcount in ado.net?

  • 12 years ago

    Hi everyone!

    I'm having problem in my codes, i don't know if how will i know how many records my query got. Because I'm planning to use it to set the maximum property of the progress bar. Hope you can help me on this. Thanks.

    Please see my codes below:




    Class frmClean

    Private Sub btnCleanUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCleanUp.Click

    Dim accConn As OleDb.OleDbConnection

    Dim accRec As OleDbDataReader

    Dim accComm As OleDbCommand

    accConn =

    New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\IRM\PCCW\MIGRATION\ACCPAC TO DSMP\ACCPAC to DSMP.mdb;Persist Security Info=False")


    accComm = accConn.CreateCommand()

    accComm.CommandText =

    "Select * From tblUnifiedAD"


    accRec = accComm.ExecuteReader


    pbar.Minimum = 1

    pbar.Maximum = ???? <Should be the record count of my query>

    pbar.Value = 1

    pbar.Step = 1

    Do While accRec.Read

       ...Some codes here.....




    End Sub





    Hope you can help me on this...

    Thanks a lot!


  • 12 years ago
    Hi Reivax

     Exp for geting recordcount

    sqlcmd = New SqlCeCommand(sqlstmt, global_dbconnection)

    sqlcmd.CommandText = sqlstmt

    maxID = sqlcmd.ExecuteScalar()

    I hope this may solve your problem.

    Good Luck

    Hari K

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe