Hi! I'm new to ADO.Net and am using VB .Net to generate a report based on an Access database. Using code (not controls) I can connect to the database fine and pull out data as I need to, but since I've got to calculate data from various tables, I'm wondering what is the best way to run multiple SQL Select statements on the data. Right now I get the data as follows:
This gives me the contents of "tblMain" in objDataSet, which is good and what I need for some things. But what if I want to query specific parts of what's in objDataSet, or what if I want to access a different table?
Do I need to close objAdapter, open it again and then fill objData set for each new SQL query I run? It seems to me it would be pretty slow to do this multiple times, and there must be some way to work with the data that's there already (from "SELECT * FROM tblMain"), but maybe there isn't. Any advice?
Please note, I don't want to use any data access controls. I can connect to the data fine like this, I'm just not sure that opening and closing the DataAdapter (or having a whole bunch of them) would be the most efficient way to run multiple queries.
Thanks! -- Mike
Code:
objConn.Open()
Dim objAdapter As New OleDbDataAdapter("SELECT * FROM tblMain", objConn)
Dim objDataSet As New DataSet
objAdapter.Fill(objDataSet)
This gives me the contents of "tblMain" in objDataSet, which is good and what I need for some things. But what if I want to query specific parts of what's in objDataSet, or what if I want to access a different table?
Do I need to close objAdapter, open it again and then fill objData set for each new SQL query I run? It seems to me it would be pretty slow to do this multiple times, and there must be some way to work with the data that's there already (from "SELECT * FROM tblMain"), but maybe there isn't. Any advice?
Please note, I don't want to use any data access controls. I can connect to the data fine like this, I'm just not sure that opening and closing the DataAdapter (or having a whole bunch of them) would be the most efficient way to run multiple queries.
Thanks! -- Mike