Results 1 to 3 of 3

Thread: Row count in access database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Location
    Vancouver, BC, Canada
    Posts
    23

    Unhappy Row count in access database

    How do I get a row count in an access database without creating a dataadapter first

    Can I just access the database directly?

    Code:
        Public m_cnADONetConnection As New OleDb.OleDbConnection
        Public m_daDataAdapter As New OleDb.OleDbDataAdapter
        Public m_cbCommandBuilder As OleDb.OleDbCommandBuilder
        Public m_dtTimeOff As New DataTable
        Public intLastTrans as Integer
    
    
            'This does work and gets my last transaction number
            m_cnADONetConnection.ConnectionString = _
                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & g_strDefaults(0) & "\" & g_strDefaults(1)
    
            m_cnADONetConnection.Open()
    
            m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
    
            m_daDataAdapter.Fill(m_dtTimeOff)
            intLastTrans = 0
            If m_dtTimeOff.Rows.Count > 0 Then intLastTrans = m_dtTimeOff.Rows(m_dtTimeOff.Rows.Count - 1)("Trans")
    
            'But seems like a lot to get just the row count of a database
    
    
            'Now I create a dataadapter based on inputed criteria
            'I need the last transaction before I do this select for future calculations
            m_daDataAdapter = _
                New OleDb.OleDbDataAdapter("Select * From TIMEOFF WHERE Badge = '" & g_strEmployeePicked & _
                "' and Round > 0", m_cnADONetConnection)
    
             m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
    
            m_daDataAdapter.Fill(m_dtTimeOff)
    This is probably an easy solution, I just can't figure it out.

    Thanks, Shozy

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    No, you must create a dataadapter to fill your dataset if you want to do anything with data from any source.
    Whadayamean it doesn't work....
    It works fine on my machine!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Location
    Vancouver, BC, Canada
    Posts
    23
    Thats the conclusion I came to also, thanks

    Shozy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width