Showing posts with label datatable. Show all posts
Showing posts with label datatable. Show all posts

Thursday, March 29, 2012

Performance problem: DataSet 2 database

Hi group,
i've got a major performance problem.

I've got a dataset with 1 datatable.
This datatable has 3 columns with the following datatypes:
string 18;
datetime
decimal

There are approx 150.000 records in the datatable.
I need to save the values to the database.
Saving the records using a sp is way to slow (12 minutes!)

Does anybody have a faster way?
Ive tried:
http://www.codeproject.com/cs/database/generic_OpenXml.asp?df=100&forumid=171911&select=1344569&msg=1344569
But this didnt work due to the datetime column.

Please help me on this one!!!

TIA

VisualSanderDon't load all 150,000 records at the same time. Is there a reason you need all 150,000 records in there? Can't you do it in batches of, say, 1000?

Monday, March 26, 2012

Performing Arithmetic on DataTable Columns

I have a DataTable with only one DataColumn of type float. I need to
calculate the Max value that in any of the DataRows, and this DataColumn.
I noticed the DataColumn has an Expression property:
http://msdn.microsoft.com/library/d...essionTopic.asp
However, it seems that I would end up having to create a new DataColumn,
call it MaxVal or something, and populate it for every row.
Is there a cleaner way?Nevermind, I discovered the Compute method.
float flMax =
(float)m_dsSegments.Tables["Calculations"].Compute("Max(Score)",
string.Empty);
"George Durzi" <gdurzi@.hotmail.com> wrote in message
news:O30tjLLTEHA.240@.TK2MSFTNGP11.phx.gbl...
> I have a DataTable with only one DataColumn of type float. I need to
> calculate the Max value that in any of the DataRows, and this DataColumn.
> I noticed the DataColumn has an Expression property:
>
http://msdn.microsoft.com/library/d...essionTopic.asp
> However, it seems that I would end up having to create a new DataColumn,
> call it MaxVal or something, and populate it for every row.
> Is there a cleaner way?
>
If your contents are bound to a dataset why don't you just use the dataset
ds.Tables[0].Compute("Max(["+strColumnName+"])",String.Empty)
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"George Durzi" <gdurzi@.hotmail.com> wrote in message
news:O30tjLLTEHA.240@.TK2MSFTNGP11.phx.gbl...
>I have a DataTable with only one DataColumn of type float. I need to
> calculate the Max value that in any of the DataRows, and this DataColumn.
> I noticed the DataColumn has an Expression property:
> http://msdn.microsoft.com/library/d...opi
c.asp
> However, it seems that I would end up having to create a new DataColumn,
> call it MaxVal or something, and populate it for every row.
> Is there a cleaner way?
>

Performing Arithmetic on DataTable Columns

I have a DataTable with only one DataColumn of type float. I need to
calculate the Max value that in any of the DataRows, and this DataColumn.

I noticed the DataColumn has an Expression property:
http://msdn.microsoft.com/library/d...essionTopic.asp

However, it seems that I would end up having to create a new DataColumn,
call it MaxVal or something, and populate it for every row.

Is there a cleaner way?Nevermind, I discovered the Compute method.

float flMax =
(float)m_dsSegments.Tables["Calculations"].Compute("Max(Score)",
string.Empty);

"George Durzi" <gdurzi@.hotmail.com> wrote in message
news:O30tjLLTEHA.240@.TK2MSFTNGP11.phx.gbl...
> I have a DataTable with only one DataColumn of type float. I need to
> calculate the Max value that in any of the DataRows, and this DataColumn.
> I noticed the DataColumn has an Expression property:
http://msdn.microsoft.com/library/d...essionTopic.asp
> However, it seems that I would end up having to create a new DataColumn,
> call it MaxVal or something, and populate it for every row.
> Is there a cleaner way?
If your contents are bound to a dataset why don't you just use the dataset
ds.Tables[0].Compute("Max(["+strColumnName+"])",String.Empty)

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"George Durzi" <gdurzi@.hotmail.com> wrote in message
news:O30tjLLTEHA.240@.TK2MSFTNGP11.phx.gbl...
>I have a DataTable with only one DataColumn of type float. I need to
> calculate the Max value that in any of the DataRows, and this DataColumn.
> I noticed the DataColumn has an Expression property:
> http://msdn.microsoft.com/library/d...essionTopic.asp
> However, it seems that I would end up having to create a new DataColumn,
> call it MaxVal or something, and populate it for every row.
> Is there a cleaner way?

Friday, March 16, 2012

Persist DataTable Values

Hi All:

I have a DataTable that I have defined Globally. I populate this datatable
dynamically with file/folder information that I read directly from the
server. I use this datatable information to bind mainly to a DataGrid, but
I would also like it to persist for the duration that I have a particular
page open. I seem to be losing this data either thru postbacks or by the
way I have coded it. Does anyone have any suggestions on how I can keep
this datatable in memory? TIA

--

Best regards

Paul Perot
President
Perot Solutions
perotsolutions@dotnet.itags.org.earthlink.net
(770) 565 - 9151
(678) 852 - 7789 (c)You began by saying that the DataTable is "defined Globally." What does that
mean? Global to what? Obviously, it isn't truly global, or you wouldn't be
asking how to persist it. For example, if it was global to the Application
(in Application Cache, for example), you wouldn't need to persist it in any
other way. It would be truly global.

I only asked that to get you thinking along these lines, hopefully so that
this situation would not rear its ugly head again for you. The issue here is
scope. And a good understanding of ASP.Net scope is what is needed to
resolve it and any future issues of scope that may arise.

I suspect that by "defined Globally" you mean that you declared a variable
with Page scope, that is, defined in your Page class as a Field or Property
of your Page class, not inside a Method. However, the scope of such a
variable is global to only a single Page instance, and each Request for a
Page creates a new Page instance. A PostBack will not see the value of a
variable declared in a previous instance of this Page class, as the variable
will be re-initialized with the initialization of the Page class.

As you've defined the requirement that this variable be global to all
instances of this Page class (within the context of a single initial Request
and the related group of PostBacks), you could declare it as static (Shared
in VB.Net) in the Page class, or, if you want it re-initialized with each
non-PostBack (initial Request), you could put it into the Page's ViewState
or in Session. If you put it into ViewState, the size of it may affect the
time it takes for the Page to load in the browser (ViewState being a hidden
form field in the HTML form). The advantage of ViewState is that the
variable will disappear as soon as a different Page is Requested. If you use
Session, the Page will have to re-initialize the Session value when it is
Requested via non-PostBack (initial Request).

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Paul Perot" <perotsolutions@.earthlink.net> wrote in message
news:CyjCb.332$X97.100@.newsread2.news.atl.earthlin k.net...
> Hi All:
> I have a DataTable that I have defined Globally. I populate this
datatable
> dynamically with file/folder information that I read directly from the
> server. I use this datatable information to bind mainly to a DataGrid,
but
> I would also like it to persist for the duration that I have a particular
> page open. I seem to be losing this data either thru postbacks or by the
> way I have coded it. Does anyone have any suggestions on how I can keep
> this datatable in memory? TIA
> --
> Best regards
> Paul Perot
> President
> Perot Solutions
> perotsolutions@.earthlink.net
> (770) 565 - 9151
> (678) 852 - 7789 (c)