HLRosenberger
asked on
MS access and calling saved Queries
From VB.NET code, I'm calling a query saved in an Access database. Is there a way to call multiple saved queries, each of which return a set of records, and get back each set of records in a DataTable within a in DataSet? Here's my current code:
Dim con As OleDbConnection = New OleDbConnection("Provider= Microsoft. JET.oledb. 4.0;data source=C:\MyAccess\service .mdb")
Dim cmd As New OleDbCommand
cmd.CommandType = CommandType.StoredProcedur e
cmd.CommandText = "GetWorkOrder"
cmd.Parameters.Add("@Local ID", OleDbType.Integer).Value = 35
Try
cmd.Connection = con
con.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim dt As New DataTable
Dim ds As DataSet = New DataSet()
da.Fill(ds, "WorkOrder")
dt = ds.Tables("WorkOrder")
con.Close()
con.Dispose()
Catch ex As Exception
End Try
Dim con As OleDbConnection = New OleDbConnection("Provider=
Dim cmd As New OleDbCommand
cmd.CommandType = CommandType.StoredProcedur
cmd.CommandText = "GetWorkOrder"
cmd.Parameters.Add("@Local
Try
cmd.Connection = con
con.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim dt As New DataTable
Dim ds As DataSet = New DataSet()
da.Fill(ds, "WorkOrder")
dt = ds.Tables("WorkOrder")
con.Close()
con.Dispose()
Catch ex As Exception
End Try
ASKER
But that hits the database three time, correct? it requires three open connections, correct? I was looking to do this to improve speed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
Open in new window