How DataSet works?

  • Thread starter Thread starter Mojtaba Faridzad
  • Start date Start date
M

Mojtaba Faridzad

Hi,

I am a newbie! I am wondering how DataSet keeps the data. I am using MySQL
as database engine. when I use "Fill" method to set a table in DataSet, does
C# retreive all data (base on Select statement) to the local computer's
memory? if we retreive 100,000 records, does it take a while to load them?

another question that I am not sure about it. can we create a table in
DataSet without relation to MySQL database? I'd like to create a temporary
table on a local computer's memory (not on the server). is that possible?
how?

thanks in advance
 
The entire set is loaded into memory on the machine using the DataSet. It is
pulled as XML. For huge recordsets, you may notice it taking awhile. I
cannot comment on 100,000 records, as I do not know the column lengths. It
could be slow.

The ADO.NET model allows you to create a new Table programatically.

1. Create a DataTable object

DataTable dt = new DataTable();

2. Create columns for the data table

DataColumn dc = new DataColumn("ColumnName");
dt.Columns.Add(dc);

3. Create a new row and fill each column

DataRow dr = new DataRow();
dr["ColumnName"] = "some value";
dt.Rows.Add(dr);

4. Repeat step three until you have all rows filled

dr = new DataRow();
dr["ColumnName"] = "some other value";
dt.Rows.Add(dr);

5. Add DataTable to DataSet

ds.Tables.Add(dt);

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
thanks for your answer!

have you ever needed to show more than 100,000 records (one of my table has
450,000 records) in a DataGrid? how did you deal with it? I had this
problem before and I had to break the data to each page. when user clicks on
next page, I retreive the next page from the server. I am wondering there is
a better method in C# or not.

about your code, i typed it and it worked fine (with minor changes). after
using the temporary table, should we use Clear method to get rid of the
table? or like creating a connection, we can add the table in using( ) block
? or we have to call Dispose?

thanks again

Cowboy (Gregory A. Beamer) said:
The entire set is loaded into memory on the machine using the DataSet. It
is
pulled as XML. For huge recordsets, you may notice it taking awhile. I
cannot comment on 100,000 records, as I do not know the column lengths. It
could be slow.

The ADO.NET model allows you to create a new Table programatically.

1. Create a DataTable object

DataTable dt = new DataTable();

2. Create columns for the data table

DataColumn dc = new DataColumn("ColumnName");
dt.Columns.Add(dc);

3. Create a new row and fill each column

DataRow dr = new DataRow();
dr["ColumnName"] = "some value";
dt.Rows.Add(dr);

4. Repeat step three until you have all rows filled

dr = new DataRow();
dr["ColumnName"] = "some other value";
dt.Rows.Add(dr);

5. Add DataTable to DataSet

ds.Tables.Add(dt);

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
Mojtaba Faridzad said:
Hi,

I am a newbie! I am wondering how DataSet keeps the data. I am using
MySQL
as database engine. when I use "Fill" method to set a table in DataSet, does
C# retreive all data (base on Select statement) to the local computer's
memory? if we retreive 100,000 records, does it take a while to load them?

another question that I am not sure about it. can we create a table in
DataSet without relation to MySQL database? I'd like to create a temporary
table on a local computer's memory (not on the server). is that possible?
how?

thanks in advance
 
With ASP.NET, you can use the paging features. I am not as familiar with the
Windows version of the DataGrid, howver.

I have seen some articles on faking paging by linking primary keys from the
last record and the first record, if you need to roll your own.

If you are creating a table that could potentially exist, consider checking
the DataSet to see if it is there and clearing it. You can also add rows to
a table that already exists, if you are inclined. This can be sent back to
the database through an Update() on the DataAdapter you created the DataSet
with.

Hope this helps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
Mojtaba Faridzad said:
thanks for your answer!

have you ever needed to show more than 100,000 records (one of my table has
450,000 records) in a DataGrid? how did you deal with it? I had this
problem before and I had to break the data to each page. when user clicks on
next page, I retreive the next page from the server. I am wondering there is
a better method in C# or not.

about your code, i typed it and it worked fine (with minor changes). after
using the temporary table, should we use Clear method to get rid of the
table? or like creating a connection, we can add the table in using( ) block
? or we have to call Dispose?

thanks again

in message news:[email protected]...
The entire set is loaded into memory on the machine using the DataSet. It
is
pulled as XML. For huge recordsets, you may notice it taking awhile. I
cannot comment on 100,000 records, as I do not know the column lengths. It
could be slow.

The ADO.NET model allows you to create a new Table programatically.

1. Create a DataTable object

DataTable dt = new DataTable();

2. Create columns for the data table

DataColumn dc = new DataColumn("ColumnName");
dt.Columns.Add(dc);

3. Create a new row and fill each column

DataRow dr = new DataRow();
dr["ColumnName"] = "some value";
dt.Rows.Add(dr);

4. Repeat step three until you have all rows filled

dr = new DataRow();
dr["ColumnName"] = "some other value";
dt.Rows.Add(dr);

5. Add DataTable to DataSet

ds.Tables.Add(dt);

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
Mojtaba Faridzad said:
Hi,

I am a newbie! I am wondering how DataSet keeps the data. I am using
MySQL
as database engine. when I use "Fill" method to set a table in DataSet, does
C# retreive all data (base on Select statement) to the local computer's
memory? if we retreive 100,000 records, does it take a while to load them?

another question that I am not sure about it. can we create a table in
DataSet without relation to MySQL database? I'd like to create a temporary
table on a local computer's memory (not on the server). is that possible?
how?

thanks in advance
 
Back
Top