Loading Data from DataBase, which way is the best?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
i writing a application in C#, i have dataGrid that connect to DataSet and DataAdapter that takes data from my sql dataBase, the problem is that the form is loaded very very slow, i heared that there is a way to make the form to be loaded faster, which way is it?
today, i'm filling the dataSet and DataAdapter in the Form_load event.

thanks...
 
Gidi,

A few questions that should be answered first:

- Are you selecting only the columns you need or are you selecting more?
You should only select as many as you need.

- Are you using stored procedures or crafting a SQL statement? You should
use stored procedures if you want your query to perform faster.

- How many rows are you getting from the database? No matter how fast your
code is, if you are selecting a gazillion rows from the DB, it's going to
take time to return to your process, as well as bind to the grid and
display.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hello,
i writing a application in C#, i have dataGrid that connect to DataSet and
DataAdapter that takes data from my sql dataBase, the problem is that the
form is loaded very very slow, i heared that there is a way to make the form
to be loaded faster, which way is it?
 
Hi Nicholas,

* i'm selecting only the columns i need.
* i'm using a stored procedures.
* and i get something like 10,000 rows, and today with a program that is writen is vb6 with access dataBase, it loads it very fast, so i'm not sure that the reason is the number of rows.

what can it be?
Thanks,

Nicholas Paldino said:
Gidi,

A few questions that should be answered first:

- Are you selecting only the columns you need or are you selecting more?
You should only select as many as you need.

- Are you using stored procedures or crafting a SQL statement? You should
use stored procedures if you want your query to perform faster.

- How many rows are you getting from the database? No matter how fast your
code is, if you are selecting a gazillion rows from the DB, it's going to
take time to return to your process, as well as bind to the grid and
display.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Gidi said:
Hello,
i writing a application in C#, i have dataGrid that connect to DataSet and
DataAdapter that takes data from my sql dataBase, the problem is that the
form is loaded very very slow, i heared that there is a way to make the form
to be loaded faster, which way is it?
today, i'm filling the dataSet and DataAdapter in the Form_load event.

thanks...
 
Hi,


Gidi said:
Hi Nicholas,

* i'm selecting only the columns i need.
* i'm using a stored procedures.
* and i get something like 10,000 rows, and today with a program that is
writen is vb6 with access dataBase, it loads it very fast, so i'm not sure
that the reason is the number of rows.
what can it be?

Hi,

Did you try to use a SqlDataReader ?

The good part of using a DataReader is that it;s faster as it's a
serverside forward only cursor ( which was the default behavior of ADO used
in VB6 ) ,
From MSDN:
Use the SqlDataReader class for a fast forward-only data cursor. The
SqlDataReader class provides a means to read a forward-only data stream
retrieved from a SQL Server database. If situations arise while you are
creating an ASP.NET application that allow you to use it, the SqlDataReader
class offers higher performance than the DataSet class. This is the case
because SqlDataReader uses SQL Server's native network data-transfer format
to read data directly from a database connection. Also, the SqlDataReader
class implements the IEnumerable interface, which allows you to bind data to
server controls as well. For more information, see the SqlDataReader Class.



Now the good part of using a Dataset is that the data is kept in the client
side and there is no need to access the DB , you have to choose depending of
your escenario which one to use.

hint:
you could use an splash screen while loading the data.


Cheers,
 
Back
Top