473,797 Members | 3,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable.NewRo w() clears previous row?! BUG?

I have a datagrid with a dataview(create d from a DataTable) bind to it. It displayes coordinates and I have a toolbarbutton that will create a set of new coordinates just like the existing ones, accept that the x-values is mirrored. It's also possible to remove these coordinates, by a method that removes any row with negative x-values. This usually works fine a few times, mirroring and then removing. But then suddenly the NewRow statement returns the same object as the last one in my DataRowCollecti on!?! I've put traces just before and after the NewRow statement, and the last DataRow in the DataTables DataRowCollecti on is cleared and sat the the same object as the onw returned from newRow!?! THAT my friends seem to me like a BUG!
I've also put traces to see what the DataView(commin g from the datagrid) contains, and just after the NewRow statement the last DataRowView becomes DETACHED!?!

int start = noOfCoordinates - 1;
DataRow newRow;
for( int i = start; i >= 0; i-- )
{
newRow = myDataTable.New Row();
newRow.ItemArra y = new object[] {
Guid.NewGuid(),
NextSequenseNum ber(),
++noOfCoordinat es,
-1 * coords[i][0],
coords[i][1] };
myDataTable.Row s.Add( newRow );
myDataTable.Acc eptChanges();
}

Any ideas folks? Cause I'm really frustrated know... :-P

Kind regards/
Tomas R
Nov 15 '05 #1
1 2580
Here's some trace output before NewRow:
*___
Unchanged, False; 1, 500, 4600
Unchanged, False; 2, 500, 5000
Unchanged, False; 3, 500, 4600
Unchanged, False; 4, -500, 4600
Unchanged, False; 5, -500, 5000
*___

Current, Unchanged, False; IsEdit
Current, Unchanged, False; 2, 500, 5000
Current, Unchanged, False; 3, 500, 4600
Current, Unchanged, False; 4, -500, 4600
Current, Unchanged, False; 5, -500, 5000

And here's some trace output just after NewRow

___*
Unchanged, False; 1, 500, 4600
Unchanged, False; 2, 500, 5000
Unchanged, False; 3, 500, 4600
Unchanged, False; , , <--------The values have dissappered?!
Unchanged, False; 5, -500, 5000
___*

Current, Unchanged, False; IsEdit
Current, Unchanged, False; 2, 500, 5000
Current, Unchanged, False; 3, 500, 4600
Current, Detached, False; IsEdit <-------The DataRowView hase become Detached?!
Current, Unchanged, False; 5, -500, 5000

An unhandled exception of type 'System.Data.Co nstraintExcepti on' occurred in system.data.dll
Additional information: Column 'figurid, figursekvensnr, sekvensnr' is constrained to be unique. Value 'de41ab35-63be-489d-be9d-f9a48c8e4b6c, 2, 6' is already present.

Well, why not even include some of the trace code. I'll do anything to get some help on this issue:

if( dgKoordinater.D ataSource is DataView )
{
DataView dv = (DataView) dgKoordinater.D ataSource;
DataTable tab = dv.Table;
if( tab.Rows.Count > 0 )
{
System.Diagnost ics.Debug.Write Line( gagga );
foreach( DataRow row in tab.Rows )
{
System.Diagnost ics.Debug.Write ( row.RowState.To String() + ", " + row.HasErrors );
try{
System.Diagnost ics.Debug.Write Line("; " + row[2].ToString() + ", " + row[3].ToString() + ", " + row[4].ToString() );
} catch { System.Diagnost ics.Debug.Write Line("; *");
}
}
}
if( dv.Count > 0 )
{
System.Diagnost ics.Debug.Write Line( gagga );
foreach( DataRowView row in dv )
{
System.Diagnost ics.Debug.Write ( row.RowVersion. ToString() + ", " + row.Row.RowStat e.ToString() + ", " + row.Row.HasErro rs );
if( row.IsNew )
System.Diagnost ics.Debug.Write Line("; IsNew");
else if( row.IsEdit )
System.Diagnost ics.Debug.Write Line("; IsEdit");
else
System.Diagnost ics.Debug.Write Line("; " + row[2].ToString() + ", " + row[3].ToString() + ", " + row[4].ToString() )
}
}

"Tomas R" <no*****@please .nu> skrev i meddelandet news:en******** *****@TK2MSFTNG P12.phx.gbl...
I have a datagrid with a dataview(create d from a DataTable) bind to it. It displayes coordinates and I have a toolbarbutton that will create a set of new coordinates just like the existing ones, accept that the x-values is mirrored. It's also possible to remove these coordinates, by a method that removes any row with negative x-values. This usually works fine a few times, mirroring and then removing. But then suddenly the NewRow statement returns the same object as the last one in my DataRowCollecti on!?! I've put traces just before and after the NewRow statement, and the last DataRow in the DataTables DataRowCollecti on is cleared and sat the the same object as the onw returned from newRow!?! THAT my friends seem to me like a BUG!
I've also put traces to see what the DataView(commin g from the datagrid) contains, and just after the NewRow statement the last DataRowView becomes DETACHED!?!

int start = noOfCoordinates - 1;
DataRow newRow;
for( int i = start; i >= 0; i-- )
{
newRow = myDataTable.New Row();
newRow.ItemArra y = new object[] {
Guid.NewGuid(),
NextSequenseNum ber(),
++noOfCoordinat es,
-1 * coords[i][0],
coords[i][1] };
myDataTable.Row s.Add( newRow );
myDataTable.Acc eptChanges();
}

Any ideas folks? Cause I'm really frustrated know... :-P

Kind regards/
Tomas R
Nov 15 '05 #2

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

Similar topics

7
3401
by: Jason Callas | last post by:
I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed exception when I call the NewRow method. The number of times it happens is NOT consistent (sometimes a few times out of 10,000 and sometimes 1000+ times). The app is written in VB and I am using SyncLock everywhere the table is accessed but I am sure it...
1
2974
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
2
2123
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code here ' Dim wykszt as System.Data.DataTable Dim zatru as System.Data.DataTable Dim row as system.Data.DataRow
7
3927
by: GaryB | last post by:
I have an untyped datatable that has financial numbers and controls that were populated by code (not a simple fill from a DA). Now I want to insert subtotals into it. I wrote a sub to do so that uses InsertAt(myrow,i). When I trace through the sub it is doing the insertat and the value of i is correct. But when I bind my dataset to a datagrid all of my inserted rows are at the end? code is below. What am I doing wrong? thanks, G
2
1778
by: DraguVaso | last post by:
Hi, I need a FAST way to put the content of a file in a datatable (one record for each line in the file). I have a routine for it, but it takes me too much time (2-5 seconds for each file) to put the lines in the datatable and do some actions. Does anybody knows a faster method? The fact is: I actually only need the lines starting with "0*" and "1*".
0
4853
by: Flack | last post by:
I have pasted at the end of this message a small sample program I whipped up to do some testing. It's a form with a datagrid and two buttons. Each button clears the dataTable that is the source of the dataGrid, and then adds five rows. Button2 is the same as button1 just that it does this in a different thread (I was testing if I was having some threading issues). Anyway, it seems that the location of the call to dt.Rows.Clear()...
3
2488
by: Mike | last post by:
Dear group, I'm currrently investigating a bug within a piece of our software whereby if a DataGridView (bound directly to a DataTable) is ordered by column headers (containing lookup combo boxes where the value is the foreign key of another table), although the DataGridView is ok, the DataTable becomes out of sync. In other words, I have a Grid of customers, and if a customer name column header is clicked - the data moves in the...
1
5739
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the work manually. I am looking for an automated way. Thank you, Max
0
1774
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: //=================================================================== // The table
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10205
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9063
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5458
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4131
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.