473,473 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataSet - adding new row

If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If I add the second
row, instant.

How can I eliminate this delay?


Dim oRow As DataRow = dsOrder.Tables("PaymentsAndCredits").NewRow

oRow("ENumber") = ENumber
oRow("CNumber") = CNumber
oRow("PType") = type
oRow("PAmount") = amount
oRow("TNumber") = 0
oRow("TAdjustment") = 0
oRow("Applied") = False

dsOrder.Tables("PaymentsAndCredits").Rows.Add(oRow )

Jul 21 '05 #1
10 3968
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If I add the second
row, instant.

How can I eliminate this delay?

Dim oRow As DataRow = dsOrder.Tables("PaymentsAndCredits").NewRow

oRow("ENumber") = ENumber
oRow("CNumber") = CNumber
oRow("PType") = type
oRow("PAmount") = amount
oRow("TNumber") = 0
oRow("TAdjustment") = 0
oRow("Applied") = False

dsOrder.Tables("PaymentsAndCredits").Rows.Add(oRow )


2 seconds sounds like a very long time. Do you know which part it is
that's taking the time? Try dumping out DateTime.Now between each line,
so you can see where the time is taken.

You could just be seeing JITting, but it sounds unlikely if it's taking
2 seconds. What kind of machine is this on?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Jon,

It is running on my laptop, nothing wrong there. This is the only bottle
neck. And 2 seconds is not an exaggeration.

It occurs on the line:

dsorder.Tables("PaymentsAndCredits").rows.add(oROw )
It only happens with the first row. I redid my SQL Insert, Delete stmts
in case there was a dataType change. Nothing.

Eric.

Jon Skeet [C# MVP] wrote:
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If I add the second
row, instant.

How can I eliminate this delay?

Dim oRow As DataRow = dsOrder.Tables("PaymentsAndCredits").NewRow

oRow("ENumber") = ENumber
oRow("CNumber") = CNumber
oRow("PType") = type
oRow("PAmount") = amount
oRow("TNumber") = 0
oRow("TAdjustment") = 0
oRow("Applied") = False

dsOrder.Tables("PaymentsAndCredits").Rows.Add(oRow )


2 seconds sounds like a very long time. Do you know which part it is
that's taking the time? Try dumping out DateTime.Now between each line,
so you can see where the time is taken.

You could just be seeing JITting, but it sounds unlikely if it's taking
2 seconds. What kind of machine is this on?


Jul 21 '05 #3
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
It is running on my laptop, nothing wrong there. This is the only bottle
neck. And 2 seconds is not an exaggeration.

It occurs on the line:

dsorder.Tables("PaymentsAndCredits").rows.add(oROw )
It only happens with the first row. I redid my SQL Insert, Delete stmts
in case there was a dataType change. Nothing.


Do you have a lot of constraints involved which check other tables? Do
you get a similar hit if you just create the dataset from scratch
without involving the database anywhere, just adding simple columns?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
No I do not have a lot of constraints.

I created a second table with the same construction. But with this one I
did not try to FILL from my SQL Server database. When I add the row (as
before) I do not get the delay.

So now I know the delay is when I try to FILL the dataset and there are
no records. My first column is an IDENTITY column which I use so I can
use the UPDATE command from the dataset. When I am adding the row {using
command: dsorder.Tables("PaymentsAndCredits").rows.add(oRow )} to the
datatable I am not using this IDENTITY column (since I do not know its
value).

With my test datatable (the one I just created) I can use DBNULL.VALUE
or just leave off the entire column and I have no problem. The row adds.
(I guess this is because we never tried to place an identity value or
primary key value in this column.) Then after I add the row and UPDATE
the database, SQL Server will autofill the next value.

Jon, What can I do with the first column (the IDENTITY column) without
a value? Or is there a way I can FILL my datatable without using this
IDENTITY column and still UPDATE any changes?

I hope this is clear. Thanks.

Eric.
Jon Skeet [C# MVP] wrote:
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
It is running on my laptop, nothing wrong there. This is the only bottle
neck. And 2 seconds is not an exaggeration.

It occurs on the line:

dsorder.Tables("PaymentsAndCredits").rows.add(oR Ow)
It only happens with the first row. I redid my SQL Insert, Delete stmts
in case there was a dataType change. Nothing.


Do you have a lot of constraints involved which check other tables? Do
you get a similar hit if you just create the dataset from scratch
without involving the database anywhere, just adding simple columns?


Jul 21 '05 #5
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
No I do not have a lot of constraints.

I created a second table with the same construction. But with this one I
did not try to FILL from my SQL Server database. When I add the row (as
before) I do not get the delay.

So now I know the delay is when I try to FILL the dataset and there are
no records.
Hang on - do you get the delay when you fill the dataset and there
*are* records?
My first column is an IDENTITY column which I use so I can
use the UPDATE command from the dataset. When I am adding the row {using
command: dsorder.Tables("PaymentsAndCredits").rows.add(oRow )} to the
datatable I am not using this IDENTITY column (since I do not know its
value).

With my test datatable (the one I just created) I can use DBNULL.VALUE
or just leave off the entire column and I have no problem. The row adds.
(I guess this is because we never tried to place an identity value or
primary key value in this column.) Then after I add the row and UPDATE
the database, SQL Server will autofill the next value.

Jon, What can I do with the first column (the IDENTITY column) without
a value? Or is there a way I can FILL my datatable without using this
IDENTITY column and still UPDATE any changes?


Unless you're wanting to modify existing records, I'd just issue a
query which doesn't fetch that column. However, I'm intrigued by this
whole business now. Could you work out a short but complete program
which does this (and nothing else - a console app would be great) and
post the table structure, so I could investigate it a bit further
myself? If all it takes is a fill and then a row addition, don't worry
about producing the code - I can do that - just the table details/query
etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #6
No. I do not get a delay if there are records.
Jon Skeet [C# MVP] wrote:
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
No I do not have a lot of constraints.

I created a second table with the same construction. But with this one I
did not try to FILL from my SQL Server database. When I add the row (as
before) I do not get the delay.

So now I know the delay is when I try to FILL the dataset and there are
no records.


Hang on - do you get the delay when you fill the dataset and there
*are* records?

My first column is an IDENTITY column which I use so I can
use the UPDATE command from the dataset. When I am adding the row {using
command: dsorder.Tables("PaymentsAndCredits").rows.add(oRow )} to the
datatable I am not using this IDENTITY column (since I do not know its
value).

With my test datatable (the one I just created) I can use DBNULL.VALUE
or just leave off the entire column and I have no problem. The row adds.
(I guess this is because we never tried to place an identity value or
primary key value in this column.) Then after I add the row and UPDATE
the database, SQL Server will autofill the next value.

Jon, What can I do with the first column (the IDENTITY column) without
a value? Or is there a way I can FILL my datatable without using this
IDENTITY column and still UPDATE any changes?


Unless you're wanting to modify existing records, I'd just issue a
query which doesn't fetch that column. However, I'm intrigued by this
whole business now. Could you work out a short but complete program
which does this (and nothing else - a console app would be great) and
post the table structure, so I could investigate it a bit further
myself? If all it takes is a fill and then a row addition, don't worry
about producing the code - I can do that - just the table details/query
etc.


Jul 21 '05 #7
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
No. I do not get a delay if there are records.


That's very strange... any luck coming up with a test program I could
investigate?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #8
Eric, try the following.
For the identity column do a FillSchema before you do the Fill on this
table and then set
AutoIncrement = true
AutoIncrementSeed = -1
AutoIncrementStep = -1
for the identity column.
You will then have to return the Identity value using SCOPE_IDENTITY()
from the InsertCommand. I usually just RETURN SCOPE_IDENTITY(); for this
and add a parameter to the InsertCommand connected to the identity column
with a Direction of ParameterDirection.ReturnValue.

Ron Allen

"Eric Petruzzelli" <eg*@e-globalpartners.com> wrote in message
news:40**************@e-globalpartners.com...
No I do not have a lot of constraints.

I created a second table with the same construction. But with this one I
did not try to FILL from my SQL Server database. When I add the row (as
before) I do not get the delay.

So now I know the delay is when I try to FILL the dataset and there are
no records. My first column is an IDENTITY column which I use so I can
use the UPDATE command from the dataset. When I am adding the row {using
command: dsorder.Tables("PaymentsAndCredits").rows.add(oRow )} to the
datatable I am not using this IDENTITY column (since I do not know its
value).

With my test datatable (the one I just created) I can use DBNULL.VALUE
or just leave off the entire column and I have no problem. The row adds.
(I guess this is because we never tried to place an identity value or
primary key value in this column.) Then after I add the row and UPDATE
the database, SQL Server will autofill the next value.

Jon, What can I do with the first column (the IDENTITY column) without
a value? Or is there a way I can FILL my datatable without using this
IDENTITY column and still UPDATE any changes?

I hope this is clear. Thanks.

Eric.
Jon Skeet [C# MVP] wrote:
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
It is running on my laptop, nothing wrong there. This is the only bottle
neck. And 2 seconds is not an exaggeration.

It occurs on the line:

dsorder.Tables("PaymentsAndCredits").rows.add(oR Ow)
It only happens with the first row. I redid my SQL Insert, Delete stmts
in case there was a dataType change. Nothing.


Do you have a lot of constraints involved which check other tables? Do
you get a similar hit if you just create the dataset from scratch
without involving the database anywhere, just adding simple columns?

Jul 21 '05 #9
Jon,

I created a test program for you to look at. There was no delay on the
test program. So, I then looked to see what is different?

I found that I had a dataview filtering from my dataTable. Whenever I
had at least 1 record in my dataview already, my dataview updates
without a hitch. But the problem was when I filtered the dataview and it
contained no records (not the datatable). If I then add a new record
(the first one with the particular filter criteria) the program stalls
(2-3 seconds) in order to update the new dataview with the new criteria
(which I do want it to update).

Therefore, what I did is place a count when adding the new record. If
the count of the dataview is zero I dispose of this dataview and
recreate a new one then reset it as the datasource on my usercontrol. I
don't know if this is the most efficient way, but for now it works.

Are the dataviews supposed to act in this fashion?

Jon, thank you for your help.

eric.

Jon Skeet [C# MVP] wrote:
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
No. I do not get a delay if there are records.


That's very strange... any luck coming up with a test program I could
investigate?


Jul 21 '05 #10
Eric Petruzzelli <eg*@e-globalpartners.com> wrote:
I created a test program for you to look at. There was no delay on the
test program. So, I then looked to see what is different?

I found that I had a dataview filtering from my dataTable. Whenever I
had at least 1 record in my dataview already, my dataview updates
without a hitch. But the problem was when I filtered the dataview and it
contained no records (not the datatable). If I then add a new record
(the first one with the particular filter criteria) the program stalls
(2-3 seconds) in order to update the new dataview with the new criteria
(which I do want it to update).

Therefore, what I did is place a count when adding the new record. If
the count of the dataview is zero I dispose of this dataview and
recreate a new one then reset it as the datasource on my usercontrol. I
don't know if this is the most efficient way, but for now it works.

Are the dataviews supposed to act in this fashion?


I'm pretty sure they're not - that does sound very odd (if I followed
you correctly). Anyone else had that experience?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #11

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

Similar topics

0
by: lgdev | last post by:
I am using a Dataset with two tables (Customer, Order) and adding a DataRelation object with Nested property set to True. I do not have a schema defined for the dataset. Calling GetXml results in...
5
by: Mike | last post by:
I need to expand the DataSet class by inheriting from it and adding functions that work on the data in the tables. However, since I can't upcast how can I get my base DataSet object assigned an...
9
by: Dave | last post by:
Compilier will not recognize DataSet object. As you can see below is from a test simple form with no other code. I'm just trying to get any Aspx form to recognize the DataSet object. You can...
16
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill...
6
by: Mark | last post by:
I'm trying to add a table to a dataset but get the error: "A DataTable named 'BordDates0040' already belongs to this DataSet." Code: Dim dtBordDates As DataTable dtBordDates =...
4
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the...
0
by: AboutJAV | last post by:
I created a crystal report with the report.rpt reportdata.xsd I created the a new dataset with the reportdata myreportdata = new reportdata(); That automatically created a new dataset...
8
by: Harry Strybos | last post by:
Visual Studio 2005 - SP1 - VB.Net on WinXP SP2 I add a typed dataset to my solution and get the following errors : Error 1 sub 'ReadXmlSerializable' cannot be declared 'Overrides' because it...
1
by: vbDavidC | last post by:
I am adding a new record to a table via a dataset/adapter. I have got the following to work for me but I am wondering if there is a better way to do this. I am having to have something in my...
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
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.