|
-
Jul 11th, 2004, 11:46 AM
#1
Thread Starter
Junior Member
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
-
Jul 12th, 2004, 11:50 AM
#2
Hyperactive Member
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!

-
Jul 12th, 2004, 05:37 PM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|