PC Review


Reply
Thread Tools Rate Thread

Adding record to disconnected DataTable slow

 
 
Turtle MacDermott
Guest
Posts: n/a
 
      11th Jan 2005
I have an ADO.NET datatable which I created from scratch - just defined its
columns and started adding data.
I find that when I step through adding a row in the debugger, it's quite
slow - up to several seconds - at the point where I actually add the row to
the table.

Any ideas?

TIA
- Turtle


 
Reply With Quote
 
 
 
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      11th Jan 2005
How many rows are you adding?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Turtle MacDermott" <(E-Mail Removed)> wrote in message
news:%238eIHcB%(E-Mail Removed)...
>I have an ADO.NET datatable which I created from scratch - just defined its
>columns and started adding data.
> I find that when I step through adding a row in the debugger, it's quite
> slow - up to several seconds - at the point where I actually add the row
> to the table.
>
> Any ideas?
>
> TIA
> - Turtle
>



 
Reply With Quote
 
MacDermott
Guest
Posts: n/a
 
      12th Jan 2005
I'm only adding one row at a time.
The table is the datasource for a datagrid.
It has 8 fields.

Currently, the first row is added and displays correctly.
The second one throws a NullReferenceException which I can't seem to trap,
even though I have a Try - Catch around the line of code which adds the row
to the table and generates the error.

I would be incredibly grateful for any insights you might be able to offer!

TIA
- Turtle

"William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
news:u8ii%23tB%(E-Mail Removed)...
> How many rows are you adding?
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no

rights.
> __________________________________
>
> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
> news:%238eIHcB%(E-Mail Removed)...
> >I have an ADO.NET datatable which I created from scratch - just defined

its
> >columns and started adding data.
> > I find that when I step through adding a row in the debugger, it's quite
> > slow - up to several seconds - at the point where I actually add the row
> > to the table.
> >
> > Any ideas?
> >
> > TIA
> > - Turtle
> >

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      12th Jan 2005
Turtle,

We probably would need to see what else you have going on with your
datatable besides 8 columns. 8 columns in itself is not such a big deal - it
certainly shouldn't throw an exception in most simplistic cases.

But there could be constraints on the datatable that might take time. There
could be weird datatypes specified, there could be relations, there could be
firing events .. who knows what else.

The reasons for the long inserts could be manifold, but let me assure you, a
simple datatable with 8 simple columns and a new row added into it shouldn't
be slow.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik




"MacDermott" <(E-Mail Removed)> wrote in message
news:uqfaFYE%(E-Mail Removed)...
> I'm only adding one row at a time.
> The table is the datasource for a datagrid.
> It has 8 fields.
>
> Currently, the first row is added and displays correctly.
> The second one throws a NullReferenceException which I can't seem to trap,
> even though I have a Try - Catch around the line of code which adds the
> row
> to the table and generates the error.
>
> I would be incredibly grateful for any insights you might be able to
> offer!
>
> TIA
> - Turtle
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:u8ii%23tB%(E-Mail Removed)...
>> How many rows are you adding?
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no

> rights.
>> __________________________________
>>
>> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
>> news:%238eIHcB%(E-Mail Removed)...
>> >I have an ADO.NET datatable which I created from scratch - just defined

> its
>> >columns and started adding data.
>> > I find that when I step through adding a row in the debugger, it's
>> > quite
>> > slow - up to several seconds - at the point where I actually add the
>> > row
>> > to the table.
>> >
>> > Any ideas?
>> >
>> > TIA
>> > - Turtle
>> >

>>
>>

>
>



 
Reply With Quote
 
MacDermott
Guest
Posts: n/a
 
      12th Jan 2005
I'm just getting the hang of ADO.NET, so I'm probably doing something unwise
here.
I've got other very similar code which seems to work fine.

Of my 8 columns, the first is a date/time type; the rest are integers and
doubles, about half each.
I have no relations defined.
I'm not at all sure what a firing event would mean in this case;
it's just a completely disconnected datatable; I create it using the New
keyword and add the columns one by one.

Would it help if I used a primary key?

- Turtle

"Sahil Malik" <(E-Mail Removed)> wrote in message
news:OmRvEWG%(E-Mail Removed)...
> Turtle,
>
> We probably would need to see what else you have going on with your
> datatable besides 8 columns. 8 columns in itself is not such a big deal -

it
> certainly shouldn't throw an exception in most simplistic cases.
>
> But there could be constraints on the datatable that might take time.

There
> could be weird datatypes specified, there could be relations, there could

be
> firing events .. who knows what else.
>
> The reasons for the long inserts could be manifold, but let me assure you,

a
> simple datatable with 8 simple columns and a new row added into it

shouldn't
> be slow.
>
> - Sahil Malik
> http://dotnetjunkies.com/weblog/sahilmalik
>
>
>
>
> "MacDermott" <(E-Mail Removed)> wrote in message
> news:uqfaFYE%(E-Mail Removed)...
> > I'm only adding one row at a time.
> > The table is the datasource for a datagrid.
> > It has 8 fields.
> >
> > Currently, the first row is added and displays correctly.
> > The second one throws a NullReferenceException which I can't seem to

trap,
> > even though I have a Try - Catch around the line of code which adds the
> > row
> > to the table and generates the error.
> >
> > I would be incredibly grateful for any insights you might be able to
> > offer!
> >
> > TIA
> > - Turtle
> >
> > "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> > news:u8ii%23tB%(E-Mail Removed)...
> >> How many rows are you adding?
> >>
> >> --
> >> ____________________________________
> >> William (Bill) Vaughn
> >> Author, Mentor, Consultant
> >> Microsoft MVP
> >> www.betav.com
> >> Please reply only to the newsgroup so that others can benefit.
> >> This posting is provided "AS IS" with no warranties, and confers no

> > rights.
> >> __________________________________
> >>
> >> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
> >> news:%238eIHcB%(E-Mail Removed)...
> >> >I have an ADO.NET datatable which I created from scratch - just

defined
> > its
> >> >columns and started adding data.
> >> > I find that when I step through adding a row in the debugger, it's
> >> > quite
> >> > slow - up to several seconds - at the point where I actually add the
> >> > row
> >> > to the table.
> >> >
> >> > Any ideas?
> >> >
> >> > TIA
> >> > - Turtle
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      12th Jan 2005
> Would it help if I used a primary key?
<-- Not really.

Can we see your data table creation code and data table population code?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


"MacDermott" <(E-Mail Removed)> wrote in message
news:O28PuVJ%(E-Mail Removed)...
> I'm just getting the hang of ADO.NET, so I'm probably doing something
> unwise
> here.
> I've got other very similar code which seems to work fine.
>
> Of my 8 columns, the first is a date/time type; the rest are integers and
> doubles, about half each.
> I have no relations defined.
> I'm not at all sure what a firing event would mean in this case;
> it's just a completely disconnected datatable; I create it using the
> New
> keyword and add the columns one by one.
>
> Would it help if I used a primary key?
>
> - Turtle
>
> "Sahil Malik" <(E-Mail Removed)> wrote in message
> news:OmRvEWG%(E-Mail Removed)...
>> Turtle,
>>
>> We probably would need to see what else you have going on with your
>> datatable besides 8 columns. 8 columns in itself is not such a big deal -

> it
>> certainly shouldn't throw an exception in most simplistic cases.
>>
>> But there could be constraints on the datatable that might take time.

> There
>> could be weird datatypes specified, there could be relations, there could

> be
>> firing events .. who knows what else.
>>
>> The reasons for the long inserts could be manifold, but let me assure
>> you,

> a
>> simple datatable with 8 simple columns and a new row added into it

> shouldn't
>> be slow.
>>
>> - Sahil Malik
>> http://dotnetjunkies.com/weblog/sahilmalik
>>
>>
>>
>>
>> "MacDermott" <(E-Mail Removed)> wrote in message
>> news:uqfaFYE%(E-Mail Removed)...
>> > I'm only adding one row at a time.
>> > The table is the datasource for a datagrid.
>> > It has 8 fields.
>> >
>> > Currently, the first row is added and displays correctly.
>> > The second one throws a NullReferenceException which I can't seem to

> trap,
>> > even though I have a Try - Catch around the line of code which adds the
>> > row
>> > to the table and generates the error.
>> >
>> > I would be incredibly grateful for any insights you might be able to
>> > offer!
>> >
>> > TIA
>> > - Turtle
>> >
>> > "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
>> > news:u8ii%23tB%(E-Mail Removed)...
>> >> How many rows are you adding?
>> >>
>> >> --
>> >> ____________________________________
>> >> William (Bill) Vaughn
>> >> Author, Mentor, Consultant
>> >> Microsoft MVP
>> >> www.betav.com
>> >> Please reply only to the newsgroup so that others can benefit.
>> >> This posting is provided "AS IS" with no warranties, and confers no
>> > rights.
>> >> __________________________________
>> >>
>> >> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
>> >> news:%238eIHcB%(E-Mail Removed)...
>> >> >I have an ADO.NET datatable which I created from scratch - just

> defined
>> > its
>> >> >columns and started adding data.
>> >> > I find that when I step through adding a row in the debugger, it's
>> >> > quite
>> >> > slow - up to several seconds - at the point where I actually add the
>> >> > row
>> >> > to the table.
>> >> >
>> >> > Any ideas?
>> >> >
>> >> > TIA
>> >> > - Turtle
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      12th Jan 2005
How MANY rows are you adding? How many rows does the DataSet have? How many
do you plan to read into the DataSet?

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"MacDermott" <(E-Mail Removed)> wrote in message
news:uqfaFYE%(E-Mail Removed)...
> I'm only adding one row at a time.
> The table is the datasource for a datagrid.
> It has 8 fields.
>
> Currently, the first row is added and displays correctly.
> The second one throws a NullReferenceException which I can't seem to trap,
> even though I have a Try - Catch around the line of code which adds the
> row
> to the table and generates the error.
>
> I would be incredibly grateful for any insights you might be able to
> offer!
>
> TIA
> - Turtle
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:u8ii%23tB%(E-Mail Removed)...
>> How many rows are you adding?
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no

> rights.
>> __________________________________
>>
>> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
>> news:%238eIHcB%(E-Mail Removed)...
>> >I have an ADO.NET datatable which I created from scratch - just defined

> its
>> >columns and started adding data.
>> > I find that when I step through adding a row in the debugger, it's
>> > quite
>> > slow - up to several seconds - at the point where I actually add the
>> > row
>> > to the table.
>> >
>> > Any ideas?
>> >
>> > TIA
>> > - Turtle
>> >

>>
>>

>
>



 
Reply With Quote
 
MacDermott
Guest
Posts: n/a
 
      13th Jan 2005
Gracious!
How can I state it more clearly?
I am using a Data Table, not a DataSet.
When I create the table, it's empty.
I add one row -
this is slow, but it works.
Then I try to add another row,
and get an untrappable NullReferenceException.

That's as far as I've gotten.
Each row represents the results of a testing cycle for an attached machine.
I'd like to let my users run the machine as long as they like (even
overnight, or several days), but if you feel it's important to limit the
number of records, perhaps you could advise me on a suitable limit.

TIA
- Turtle

"William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
news:uQTlykN%(E-Mail Removed)...
> How MANY rows are you adding? How many rows does the DataSet have? How

many
> do you plan to read into the DataSet?
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no

rights.
> __________________________________
>
> "MacDermott" <(E-Mail Removed)> wrote in message
> news:uqfaFYE%(E-Mail Removed)...
> > I'm only adding one row at a time.
> > The table is the datasource for a datagrid.
> > It has 8 fields.
> >
> > Currently, the first row is added and displays correctly.
> > The second one throws a NullReferenceException which I can't seem to

trap,
> > even though I have a Try - Catch around the line of code which adds the
> > row
> > to the table and generates the error.
> >
> > I would be incredibly grateful for any insights you might be able to
> > offer!
> >
> > TIA
> > - Turtle
> >
> > "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> > news:u8ii%23tB%(E-Mail Removed)...
> >> How many rows are you adding?
> >>
> >> --
> >> ____________________________________
> >> William (Bill) Vaughn
> >> Author, Mentor, Consultant
> >> Microsoft MVP
> >> www.betav.com
> >> Please reply only to the newsgroup so that others can benefit.
> >> This posting is provided "AS IS" with no warranties, and confers no

> > rights.
> >> __________________________________
> >>
> >> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
> >> news:%238eIHcB%(E-Mail Removed)...
> >> >I have an ADO.NET datatable which I created from scratch - just

defined
> > its
> >> >columns and started adding data.
> >> > I find that when I step through adding a row in the debugger, it's
> >> > quite
> >> > slow - up to several seconds - at the point where I actually add the
> >> > row
> >> > to the table.
> >> >
> >> > Any ideas?
> >> >
> >> > TIA
> >> > - Turtle
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
William \(Bill\) Vaughn
Guest
Posts: n/a
 
      13th Jan 2005
Okay, you should be able to add rows to the DataTable quite quickly. The
reason I was asking about the number of rows is that when you add a lot of
rows (thousands), the DataTable structure gets bogged down. Can we see the
code that's failing? How do you build the rows to add to the DataTable?
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"MacDermott" <(E-Mail Removed)> wrote in message
news:OivZeoR%(E-Mail Removed)...
> Gracious!
> How can I state it more clearly?
> I am using a Data Table, not a DataSet.
> When I create the table, it's empty.
> I add one row -
> this is slow, but it works.
> Then I try to add another row,
> and get an untrappable NullReferenceException.
>
> That's as far as I've gotten.
> Each row represents the results of a testing cycle for an attached
> machine.
> I'd like to let my users run the machine as long as they like (even
> overnight, or several days), but if you feel it's important to limit the
> number of records, perhaps you could advise me on a suitable limit.
>
> TIA
> - Turtle
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:uQTlykN%(E-Mail Removed)...
>> How MANY rows are you adding? How many rows does the DataSet have? How

> many
>> do you plan to read into the DataSet?
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no

> rights.
>> __________________________________
>>
>> "MacDermott" <(E-Mail Removed)> wrote in message
>> news:uqfaFYE%(E-Mail Removed)...
>> > I'm only adding one row at a time.
>> > The table is the datasource for a datagrid.
>> > It has 8 fields.
>> >
>> > Currently, the first row is added and displays correctly.
>> > The second one throws a NullReferenceException which I can't seem to

> trap,
>> > even though I have a Try - Catch around the line of code which adds the
>> > row
>> > to the table and generates the error.
>> >
>> > I would be incredibly grateful for any insights you might be able to
>> > offer!
>> >
>> > TIA
>> > - Turtle
>> >
>> > "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
>> > news:u8ii%23tB%(E-Mail Removed)...
>> >> How many rows are you adding?
>> >>
>> >> --
>> >> ____________________________________
>> >> William (Bill) Vaughn
>> >> Author, Mentor, Consultant
>> >> Microsoft MVP
>> >> www.betav.com
>> >> Please reply only to the newsgroup so that others can benefit.
>> >> This posting is provided "AS IS" with no warranties, and confers no
>> > rights.
>> >> __________________________________
>> >>
>> >> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
>> >> news:%238eIHcB%(E-Mail Removed)...
>> >> >I have an ADO.NET datatable which I created from scratch - just

> defined
>> > its
>> >> >columns and started adding data.
>> >> > I find that when I step through adding a row in the debugger, it's
>> >> > quite
>> >> > slow - up to several seconds - at the point where I actually add the
>> >> > row
>> >> > to the table.
>> >> >
>> >> > Any ideas?
>> >> >
>> >> > TIA
>> >> > - Turtle
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      13th Jan 2005
Hey Turtle,

Are you adding rows - with the datatable associated as the datasource for
the datagrid?

Can you try a quick experiment ? Disassociate the DataTable with any
Databindings it might be a part of. Also any dataviews that might be built
upon it.

Now add the row ... is it still slow?

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



"MacDermott" <(E-Mail Removed)> wrote in message
news:OivZeoR%(E-Mail Removed)...
> Gracious!
> How can I state it more clearly?
> I am using a Data Table, not a DataSet.
> When I create the table, it's empty.
> I add one row -
> this is slow, but it works.
> Then I try to add another row,
> and get an untrappable NullReferenceException.
>
> That's as far as I've gotten.
> Each row represents the results of a testing cycle for an attached
> machine.
> I'd like to let my users run the machine as long as they like (even
> overnight, or several days), but if you feel it's important to limit the
> number of records, perhaps you could advise me on a suitable limit.
>
> TIA
> - Turtle
>
> "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
> news:uQTlykN%(E-Mail Removed)...
>> How MANY rows are you adding? How many rows does the DataSet have? How

> many
>> do you plan to read into the DataSet?
>>
>> --
>> ____________________________________
>> William (Bill) Vaughn
>> Author, Mentor, Consultant
>> Microsoft MVP
>> www.betav.com
>> Please reply only to the newsgroup so that others can benefit.
>> This posting is provided "AS IS" with no warranties, and confers no

> rights.
>> __________________________________
>>
>> "MacDermott" <(E-Mail Removed)> wrote in message
>> news:uqfaFYE%(E-Mail Removed)...
>> > I'm only adding one row at a time.
>> > The table is the datasource for a datagrid.
>> > It has 8 fields.
>> >
>> > Currently, the first row is added and displays correctly.
>> > The second one throws a NullReferenceException which I can't seem to

> trap,
>> > even though I have a Try - Catch around the line of code which adds the
>> > row
>> > to the table and generates the error.
>> >
>> > I would be incredibly grateful for any insights you might be able to
>> > offer!
>> >
>> > TIA
>> > - Turtle
>> >
>> > "William (Bill) Vaughn" <(E-Mail Removed)> wrote in message
>> > news:u8ii%23tB%(E-Mail Removed)...
>> >> How many rows are you adding?
>> >>
>> >> --
>> >> ____________________________________
>> >> William (Bill) Vaughn
>> >> Author, Mentor, Consultant
>> >> Microsoft MVP
>> >> www.betav.com
>> >> Please reply only to the newsgroup so that others can benefit.
>> >> This posting is provided "AS IS" with no warranties, and confers no
>> > rights.
>> >> __________________________________
>> >>
>> >> "Turtle MacDermott" <(E-Mail Removed)> wrote in message
>> >> news:%238eIHcB%(E-Mail Removed)...
>> >> >I have an ADO.NET datatable which I created from scratch - just

> defined
>> > its
>> >> >columns and started adding data.
>> >> > I find that when I step through adding a row in the debugger, it's
>> >> > quite
>> >> > slow - up to several seconds - at the point where I actually add the
>> >> > row
>> >> > to the table.
>> >> >
>> >> > Any ideas?
>> >> >
>> >> > TIA
>> >> > - Turtle
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datatable: adding rows very slow Andrius B. Microsoft VB .NET 8 30th Nov 2009 06:29 PM
GridView / EditItemTemplate: using with disconnected DataTable? DC Microsoft ASP .NET 2 11th Apr 2008 10:21 PM
How To Insert DataTable Into MS Access (Record at a time too slow) oopman2002 Microsoft C# .NET 4 8th Aug 2006 03:36 PM
Disconnected DataSet and DataTable =?Utf-8?B?QW1ub24gUmFwb3BvcnQ=?= Microsoft ADO .NET 4 20th Dec 2005 05:37 PM
Creating a DataSet and DataTable then adding a record. Help! David Hearn Microsoft ADO .NET 2 3rd Jun 2004 01:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 AM.