M
Marcus
I have a a VB.Net app using an Oledb data connection to an Access 2000
database. There are three tables that I am using in a SELECT query:
- ReadProps (2025 records, 5 fields)
- Devices (511 records, 27 fields)
- ReadPropEnums (3060 records, 6 fields)
When I run the following SELECT statement (that returns 500 records)
directly in Access, it takes less than one second to execute:
SELECT ReadProps.RPID, ReadProps.DeviceID , ReadProps.RPname,
Devices.Label FROM ReadProps INNER JOIN Devices ON ReadProps.DeviceID
= Devices.ID WHERE ReadProps.RPID NOT IN (SELECT RPID FROM
ReadPropEnums)
However, when I run my VB.Net code, the filling of the datatable in
the line "da.Fill(dt)" takes about 15 seconds! What am I missing
here?
Here is my VB.Net code:
'--------------------------------------------
Dim conn As System.Data.OleDb.OleDbConnection
Dim connStr As String
Dim sqlSelectString as string
Dim da As OleDbDataAdapter
Dim cmd As OleDbCommand
Dim dt As DataTable
sqlSelectString = "SELECT ReadProps.RPID, ReadProps.DeviceID ,
ReadProps.RPname, Devices.Label FROM ReadProps INNER JOIN Devices ON
ReadProps.DeviceID = Devices.ID WHERE ReadProps.RPID NOT IN (SELECT
DISTINCT RPID FROM ReadPropEnums) "
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:
\test.mdb;Jet OLEDBatabase Password=123;"
conn = New System.Data.OleDb.OleDbConnection(connStr)
cmd = New OleDbCommand(sqlSelectString, conn)
da = New OleDbDataAdapter(cmd)
dt = New DataTable
conn.Open()
'filling this datatable below takes about 15 seconds! It is also the
same
da.Fill(dt)
'--------------------------------------------
By the way, I get the same poor performance using a OleDbDataReader:
Dim reader As OleDbDataReader
Dim myCmd As New OleDbCommand(sqlSelectString , conn)
reader = myCmd.ExecuteReader
While reader.Read
c1 = c1 + 1
End While
Thanks for any help.
Marcus
database. There are three tables that I am using in a SELECT query:
- ReadProps (2025 records, 5 fields)
- Devices (511 records, 27 fields)
- ReadPropEnums (3060 records, 6 fields)
When I run the following SELECT statement (that returns 500 records)
directly in Access, it takes less than one second to execute:
SELECT ReadProps.RPID, ReadProps.DeviceID , ReadProps.RPname,
Devices.Label FROM ReadProps INNER JOIN Devices ON ReadProps.DeviceID
= Devices.ID WHERE ReadProps.RPID NOT IN (SELECT RPID FROM
ReadPropEnums)
However, when I run my VB.Net code, the filling of the datatable in
the line "da.Fill(dt)" takes about 15 seconds! What am I missing
here?
Here is my VB.Net code:
'--------------------------------------------
Dim conn As System.Data.OleDb.OleDbConnection
Dim connStr As String
Dim sqlSelectString as string
Dim da As OleDbDataAdapter
Dim cmd As OleDbCommand
Dim dt As DataTable
sqlSelectString = "SELECT ReadProps.RPID, ReadProps.DeviceID ,
ReadProps.RPname, Devices.Label FROM ReadProps INNER JOIN Devices ON
ReadProps.DeviceID = Devices.ID WHERE ReadProps.RPID NOT IN (SELECT
DISTINCT RPID FROM ReadPropEnums) "
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:
\test.mdb;Jet OLEDBatabase Password=123;"
conn = New System.Data.OleDb.OleDbConnection(connStr)
cmd = New OleDbCommand(sqlSelectString, conn)
da = New OleDbDataAdapter(cmd)
dt = New DataTable
conn.Open()
'filling this datatable below takes about 15 seconds! It is also the
same
da.Fill(dt)
'--------------------------------------------
By the way, I get the same poor performance using a OleDbDataReader:
Dim reader As OleDbDataReader
Dim myCmd As New OleDbCommand(sqlSelectString , conn)
reader = myCmd.ExecuteReader
While reader.Read
c1 = c1 + 1
End While
Thanks for any help.
Marcus