How do I get a row count in an access database without creating a dataadapter first
Can I just access the database directly?
This is probably an easy solution, I just can't figure it out.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)
Thanks, Shozy




Reply With Quote