SqlDataAdapter.Fill() Performance isues

B

Baudin

Hallo all,

I have the following problem. I'm trying to fill a DataTable in a DataSet
with data from an SQL server 2000 database.
I create a SqlConnection, SqlCommand and finally an SqlDataAdapter with
which I fill a table in my DataSet with the
following code:

dt.BeginLoadData();
da.Fill(dt);
dt.EndloadData();

This statement alone takes about 4.7 secs of execution time, which I think
is way too much for a table containing only
6 rows of data containing 4 columns. Does anyone have some advice on how to
speed this up?

(have also tried the .Fill() without the BeginLoadData and EndLoadData
methods, same result)

Extra information: I'm using Visual Studio 2005 and when I run my query in
the Query Analyser it takes about 0.01 secs.
 
N

Nicholas Paldino [.NET/C# MVP]

Baudin,

What is in the table? What kind of columns are there, and how large are
they?
 
B

Baudin

Thank you for the reply Nicolas,

The table contains 4 columns, an ID column and 3 columns of type nchar (one
of which is unique). The table has 6 rows of test data. What I have been
able to assert is that the problem is less with the filling of the DataSet
and more with the binding of the controls though the DataSet. I had hoped
that because I fill the DataSet in the constructor of the form instead of in
the Form_Load event the bindings would be placed after the DataSet had been
filled. Apparently I was wrong.

I have changed my code so that the bindings occur "on the fly" and this
seems to have solved the problem. The execution time is now back to an
acceptable 0.01 seconds.

Baudin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top