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

  • 10 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:

    Imports

    System.Data.OleDb

    Public

    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")

    accConn.Open()

    accComm = accConn.CreateCommand()

    accComm.CommandText =

    "Select * From tblUnifiedAD"

    MessageBox.Show(accComm.ExecuteNonQuery)

    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.....

       pbar.PerformStep()

    Loop

    accConn.Close()

    End Sub

    End

    Class

     

     

    Hope you can help me on this...

    Thanks a lot!

    Reivax

  • 10 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

    Regards
    Hari K











Post a reply

Enter your message below

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

Contribute

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.

“XML is like violence - if it's not working for you, you're not using enough of it.”