473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dataadapter.fill

MDB
Hello All,

I have a data grid that I fill using a dataset. The results of the query
has around 15 columns and 500 rows (and growing). The reason I am using the
datagrid is so the end users can auto sort and page so I would like to keep
using the datagrid. My problem is that when I call DataAdapter.Fill, it
takes a very long time and is even causing the web page to time out. Does
anyone know why the fill is taking so long (15-20 sec) or have any better
suggestions to display the records?

SQL Sent To Function
Select user_id, password, emailaddress, firstname, lastname, address, city,
state, zip, phonenumber, marketing, admin, status, last_order from users
where status = 'A'

Primary Key on user_id
Index on Status

public DataSet LoadDataset(string sql, string tableName, DataSet ds)
{
SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);

if (ds == null) {ds = new DataSet();}
if(ds.Tables[tableName]!=null){ds.Tables[tableName].Clear();}
if (tableName == null) {tableName = "Table";}
SqlCeDataAdapter da = new SqlCeDataAdapter(dc);
da.Fill(ds, tableName);

da.Dispose();
dc.Dispose();

return ds;
}
Jul 13 '06 #1
2 5202
Hi,
First of all, searching by text fields is very very slow and not efficient.
If You have to make selection on status ( which could be also numeric
field ) do this way, searching by numeric value is faster.
Your Code:
>SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);

if (ds == null) {ds = new DataSet();}
if(ds.Tables[tableName]!=null){ds.Tables[tableName].Clear();}
if (tableName == null) {tableName = "Table";}
SqlCeDataAdapter da = new SqlCeDataAdapter(dc);
da.Fill(ds, tableName);
try do this way:
ds = null;
ds = new DataSet();
DataTable dt = new DataTable();
da.Fill(dt);
ds.Tables.add(dt)

this code is good when You use Dataset as a storage of one table, there is
no problem to create new table and fill it by dataadapter;-)

Adas
Użytkownik "MDB" <md*@nowhere.comnapisał w wiadomo¶ci
news:u%****************@TK2MSFTNGP04.phx.gbl...
Hello All,

I have a data grid that I fill using a dataset. The results of the query
has around 15 columns and 500 rows (and growing). The reason I am using
the datagrid is so the end users can auto sort and page so I would like to
keep using the datagrid. My problem is that when I call DataAdapter.Fill,
it takes a very long time and is even causing the web page to time out.
Does anyone know why the fill is taking so long (15-20 sec) or have any
better suggestions to display the records?

SQL Sent To Function
Select user_id, password, emailaddress, firstname, lastname, address,
city, state, zip, phonenumber, marketing, admin, status, last_order from
users where status = 'A'

Primary Key on user_id
Index on Status

public DataSet LoadDataset(string sql, string tableName, DataSet ds)
{
SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);

if (ds == null) {ds = new DataSet();}
if(ds.Tables[tableName]!=null){ds.Tables[tableName].Clear();}
if (tableName == null) {tableName = "Table";}
SqlCeDataAdapter da = new SqlCeDataAdapter(dc);
da.Fill(ds, tableName);

da.Dispose();
dc.Dispose();

return ds;
}

Jul 13 '06 #2
MDB
Thank you for your response. I will try switching the status to a numeric
value and using a datatable.

"tomodati" <ad***************@op.plwrote in message
news:e9**********@nemesis.news.tpi.pl...
Hi,
First of all, searching by text fields is very very slow and not
efficient. If You have to make selection on status ( which could be also
numeric field ) do this way, searching by numeric value is faster.
Your Code:
>>SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);

if (ds == null) {ds = new DataSet();}
if(ds.Tables[tableName]!=null){ds.Tables[tableName].Clear();}
if (tableName == null) {tableName = "Table";}
SqlCeDataAdapter da = new SqlCeDataAdapter(dc);
da.Fill(ds, tableName);

try do this way:
ds = null;
ds = new DataSet();
DataTable dt = new DataTable();
da.Fill(dt);
ds.Tables.add(dt)

this code is good when You use Dataset as a storage of one table, there is
no problem to create new table and fill it by dataadapter;-)

Adas
Użytkownik "MDB" <md*@nowhere.comnapisał w wiadomo¶ci
news:u%****************@TK2MSFTNGP04.phx.gbl...
>Hello All,

I have a data grid that I fill using a dataset. The results of the query
has around 15 columns and 500 rows (and growing). The reason I am using
the datagrid is so the end users can auto sort and page so I would like
to keep using the datagrid. My problem is that when I call
DataAdapter.Fill, it takes a very long time and is even causing the web
page to time out. Does anyone know why the fill is taking so long (15-20
sec) or have any better suggestions to display the records?

SQL Sent To Function
Select user_id, password, emailaddress, firstname, lastname, address,
city, state, zip, phonenumber, marketing, admin, status, last_order from
users where status = 'A'

Primary Key on user_id
Index on Status

public DataSet LoadDataset(string sql, string tableName, DataSet ds)
{
SqlCeCommand dc = new SqlCeCommand(sql, conn, trans);

if (ds == null) {ds = new DataSet();}
if(ds.Tables[tableName]!=null){ds.Tables[tableName].Clear();}
if (tableName == null) {tableName = "Table";}
SqlCeDataAdapter da = new SqlCeDataAdapter(dc);
da.Fill(ds, tableName);

da.Dispose();
dc.Dispose();

return ds;
}


Jul 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: JJ | last post by:
Hi, I created a DataAdapter, connection object and dataset generated from DataAdapter by dragging DataAdapter compenent to win form. Now in the code behind I want to use that DataAdapter. I go...
1
by: yma | last post by:
Hi, I tried to use a listbox to display a column in MS Access 2000 nwind.mdb by using ole DataAdapter, Connection and dataset controls. But I got "It is already opened exclusively by another...
20
by: TJ Doherty | last post by:
Need help understanding the following please: When I am creating a project and code my connection using Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data...
13
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
2
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
6
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection =...
3
by: Rich | last post by:
What is the diffeence bewtween a dataAdapter.InsertCommand and dataAdapter.SelectCommand (and dataAdapter.UpdateCommand for that matter)? Dim da As SqlDataAdapter conn.Open da.SelectCommand =...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.