473,657 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PK on auto increase DataColumn in DataTable cause NullReferenceEx ception

I have a program works fine in .NET 1.1 and just recompiled in .NET 2.0
without any code change. Compiles OK, but there is an exeception when
execute it.

Then I remove PK, it works all fine again.

Is this a known bug : PK on auto increase DataColumn in DataTable cause
NullReferenceEx ception?

dcLineId = new DataColumn(LINE ID_STR,
System.Type.Get Type("System.In t32"));
dt.Columns.Add( dcLineId);
dcLineId.AutoIn crement = true;
dcLineId.AutoIn crementStep =1;

//if I remove this line, it works OK again on VS 2005
this.dt.Primary Key = new DataColumn[] {dcLineId};

.......
this.dt.Rows.Ad d(dr); //execute first time OK, second time throws
NullReferenceEx ception
NullReferenceEx ception
at System.Data.Ind ex.CompareRecor ds(Int32 record1, Int32 record2)
at System.Data.Ind ex.IndexTree.Co mpareNode(Int32 record1, Int32 record2)
at System.Data.RBT ree`1.RBInsert( Int32 root_id, Int32 x_id, Int32
position)
at System.Data.Ind ex.InsertRecord (Int32 record, Boolean fireEvent)
at System.Data.Ind ex.ApplyChangeA ction(Int32 record, Int32 action)
at System.Data.Dat aTable.RecordSt ateChanged(Int3 2 record1,
DataViewRowStat e oldState1, DataViewRowStat e newState1, Int32 record2,
DataViewRowStat e oldState2, DataViewRowStat e newState2)
at System.Data.Dat aTable.SetNewRe cordWorker(Data Row row, Int32
proposedRecord, DataRowAction action, Boolean isInMerge, Int32 position,
Boolean fireEvent, Exception& deferredExcepti on)
at System.Data.Dat aTable.InsertRo w(DataRow row, Int32 proposedID, Int32
pos, Boolean fireEvent)
at System.Data.Dat aRowCollection. Add(DataRow row)

...........
Thanks,
~.~.~.~.~.~.~.~ .~.~.~.~.~.~.~. ~.~.~.~.

Ryan Liu
137 0173 5101
Shanghai Fengpu Software Co. Ltd
Shanghai , China

http://www.PowerCATI.com Powerful CATI!
http://www.fpsoft.net.cn
~.~.~.~.~.~.~.~ .~.~.~.~.~.~.~. ~.~.~.~.

Oct 29 '07 #1
0 1645

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

Similar topics

2
1826
by: frazer | last post by:
hi i have created a dataset manually. is ther any way to have auto increment in it?
3
9962
by: Mico | last post by:
I would be very grateful for any help with the following problem: I use a DataAdapter to fill a DataSet in the Page_Load method. Later, I use this DataSet to construct a DataTable, then create a DataRow and search through the DataTable for a specific row. Having found the row, I intend to display the various fields in some text boxes. This is all triggered from a dropdownlist. The code for this is shown below:
3
7179
by: Jason | last post by:
How do I hide a column in a GridView in ASP.NET 2.0 when all of the columns are autogenerated based on the datasource? I want to hide the first of three columns, but the following doesn't work: DataTable dt = new DataTable(); DataColumn dc; dc = new DataColumn(); dc.ColumnName = "blog_entry_id"; dc.DataType = System.Type.GetType("System.Int32"); dt.Columns.Add(dc);
1
7833
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I am note sure what to do because all propertiers work, except the System.Data.DataColumn.. I didn't write any code by hand and used the visual studio to set the properties..
1
1351
by: sherifffruitfly | last post by:
Hi all, I've got a form with a datagrid defined & presented to the user at runtime (code at the bottom.) With this, the user can happily enter all the data she likes. After a row of data is entered in the datagrid, and the datagrid is about to start a new row for the user, I'd like an UpdateDatabase(DataRow rowJustEntered) to be called. I suppose some kind of define-and-subscribe-to-some-event has to take place, but that's precisely...
4
1939
by: JO | last post by:
hello, how could i make to know if my column PK on access is auto increment. with .net i use Dim dtLstKP As DataTable = MyConn.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, New Object() {Nothing, Nothing, strNomTable}) thx
3
6200
by: DaveP | last post by:
im Trying to set a Datacolumn type for a new table boolean is not working, What is the correct waty //column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolean"); column.DataType = System.Type.GetType"System.Boolean"); //"System.Boolean"); tia
3
24678
by: Manuel | last post by:
Hi to all, I'm trying to copy a Datacolumn from a table to another, but with this code: destTable.Columns.Add(srcTable.Column); I got this error: Column 'colname' already belongs to another DataTable. Anyone can help me?
3
6126
by: remya1000 | last post by:
I’m using Vb.net application program. I created a datagrid having text field and checkbox fields. Everything is displaying correctly. I have 9 Columns and each columns are equally separated. In DataGrid property, I made PreferredColumnWidth = 85. So its equally aligned. I would like to give more width for the column named Department than rest of the columns. Because when its equally aligned, I can see the Departments displayed. Department...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8621
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
7354
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
6177
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
5643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.