Hi Guys,
Is there a best practise when having an ADO connection to speed up the process? Currently the method I am using below works fine but it's a little slow in getting the data.
Is there any hints, tips or tricks I can utilise to speed this up?
//Opens the Line 50 Connection//
adoConn.Open("SageLine50v19", "Manager", "", 0);
//Creates new versions of the Connection string and Data Set//
da = new OleDbDataAdapter();
ds4 = new DataSet();
if (File.Exists("C:\\twDB.xml"))
{
//Create a new Datatable called "accountsTable" and then adds that the the DataSet 4//
DataTable accountsTable = new DataTable("accounts");
ds4.Tables.Add(accountsTable);
//SQL Statement ran against the tables via ADO to get information from the Accounts table//
string query;
query = "SELECT ACCOUNT_REF AS ACCOUNT, NAME, ADDRESS_3 AS TOWN, ADDRESS_1, ADDRESS_2, ADDRESS_4, ADDRESS_5 FROM SALES_LEDGER ORDER BY ACCOUNT_REF ASC";
//Not to sure "exactly" what this does//
adoRS.Open(query, adoConn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockPessimistic, 1);
//Fills the newly created datatable using the ADO Record Set//
da.Fill(accountsTable, adoRS);
//Closes the Connection to Sage Line 50 (Read Only)//
adoRS.Close();
adoConn.Close();
//Populates the DataGridView with the information from the SQL Select Statement//
dataGridView1.DataSource = ds4.Tables[0];
dataGridView1.Columns["ADDRESS_1"].Visible = false;
dataGridView1.Columns["ADDRESS_2"].Visible = false;
dataGridView1.Columns["ADDRESS_4"].Visible = false;
dataGridView1.Columns["ADDRESS_5"].Visible = false;
Many thanks for any help offered
Regards
Mark.
UPDATE
It seems to takes about 17 seconds when pressing 'Account Customers' to load the data into the DGV which you can then select an account from. If I then select 'Cash Customers' it seems to take around the same amount of time (even though the Cash Customers are using ODBC Connection to an Access Database) ?