473,795 Members | 3,215 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataColumn Class and AutoIncrement

Sam
Hi all

I have a simple datagrid form which has 4 columns. The first one is used
just like a key and the other threes allow user to enter numbers. The
problem that I am having is that when I click on a cell of a new row but
decide not to enter a value and go back to any of the previous rows for
editting or whatever reason, the value of the new row will be incremented by
value of the AutoIncrementSt ep

Here is the problem I have

When I loaded the table for a first time, the first row has a value of 0 in
column 1. I then entered 5, 5, 5 in column 2, 3, and 4 respectively. I
clicked on the 2nd row (new row), a new value of 1 was in column 1
(everything is fine up to this point). Instead entering values for column 2,
3 and 4, I went back to my row 1 to edit the data. I then came back to my
second row and enter values for my columns 2, 3 and 4. I noticed that the
value of row 2 is now 2 not 1 and it seems like the number keeps on
incrementing.

Can we make the number increment only when an actual new row is created ? I
have included the code for column 1, all others are pretty much the same.

Dim mInputTable As New DataTable

Dim IDColStyle As New DataGridTextBox Column

Dim mIDCol As New DataColumn

'Initialize node column

mIDCol.ColumnNa me = "Node ID"

mIDCol.Caption = "Node ID"

mIDCol.AutoIncr ement = True

mIDCol.AutoIncr ementSeed = 0

mIDCol.AutoIncr ementStep = 1

mIDCol.DataType = GetType(Integer )

IDColStyle.Mapp ingName = "Node ID"

IDColStyle.Null Text = ""

IDColStyle.Widt h = 72

IDColStyle.Read Only = True

IDColStyle.Head erText = mIDCol.Caption

TableStyle.Grid ColumnStyles.Ad d(IDColStyle)

dgdInput.TableS tyles.Add(Table Style)

dgdInput.DataSo urce = mInputTable


Nov 21 '05 #1
1 1636
Sam,

I dont know why it happens in this case, however in my opinion is what is
the value of an autoincrement number is not important at all.

The value will be setted to a new number at update time, where when other
users has changed as well some row the start point will than be the actual
seed point of the database.

It is good to set the seed, the increment of that and the steps by the way.
And than use -1 for all.

http://msdn.microsoft.com/library/de...ementTopic.asp

I hope this helps something?

Cor
"Sam" <qd*@datawave.c a>
Hi all

I have a simple datagrid form which has 4 columns. The first one is used
just like a key and the other threes allow user to enter numbers. The
problem that I am having is that when I click on a cell of a new row but
decide not to enter a value and go back to any of the previous rows for
editting or whatever reason, the value of the new row will be incremented
by value of the AutoIncrementSt ep

Here is the problem I have

When I loaded the table for a first time, the first row has a value of 0
in column 1. I then entered 5, 5, 5 in column 2, 3, and 4 respectively. I
clicked on the 2nd row (new row), a new value of 1 was in column 1
(everything is fine up to this point). Instead entering values for column
2, 3 and 4, I went back to my row 1 to edit the data. I then came back to
my second row and enter values for my columns 2, 3 and 4. I noticed that
the value of row 2 is now 2 not 1 and it seems like the number keeps on
incrementing.

Can we make the number increment only when an actual new row is created ?
I have included the code for column 1, all others are pretty much the
same.

Dim mInputTable As New DataTable

Dim IDColStyle As New DataGridTextBox Column

Dim mIDCol As New DataColumn

'Initialize node column

mIDCol.ColumnNa me = "Node ID"

mIDCol.Caption = "Node ID"

mIDCol.AutoIncr ement = True

mIDCol.AutoIncr ementSeed = 0

mIDCol.AutoIncr ementStep = 1

mIDCol.DataType = GetType(Integer )

IDColStyle.Mapp ingName = "Node ID"

IDColStyle.Null Text = ""

IDColStyle.Widt h = 72

IDColStyle.Read Only = True

IDColStyle.Head erText = mIDCol.Caption

TableStyle.Grid ColumnStyles.Ad d(IDColStyle)

dgdInput.TableS tyles.Add(Table Style)

dgdInput.DataSo urce = mInputTable

Nov 21 '05 #2

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

Similar topics

1
5404
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member System.ComponentModel.MarshalByValueComponent.Site of type System.ComponentModel.ISite because it is an interface. I tried a number of workarounds without sucess:
0
1408
by: Neil | last post by:
Hi, I'm getting some strange results using the autoincrement column on my datatable. I'm populating a datatable with data from my database and displaying this in a datagrid. The first time I get the data from the database I create a new table with an autoincrement column bind the datagrid to this new table. The auto increment column is displayed as an ID col in the datagrid. The user can add records or modify records at this point, when...
5
1434
by: Larry Bird | last post by:
I've created a AlertDataClass below within the class I have tables and column that I've create. In the AlertDataAccess class I'm trying to insert data into my tables. AlertDataAccess is a Module that is trying to insert data into the tables. Within the AlertDataClass is subroutine that init and creates ColumnNames. In invoke the AddDataColumnNames() sub to create the column headers. Why can't I see the column names in my module that I'm...
6
9179
by: Michael | last post by:
I am trying to create an access database within Net 2003 using the ADOX library which works fine except when I try to add the AutoIncrement property to the ContactId column. I am experiencing a Property 'item' is ReadOnly error within the below line .Columns("ContactId").Properties("AutoIncrement") = True Am I missing a reference or what am I doing wrong?????
5
8098
by: JC Voon | last post by:
Hi: How to reset the autoincrement value generated by DataTable ? I've master and detail table, the detail table has a autoincrement column, each time i add a new master record, i need to reset the detail table autoincrement column to start from 1. I set the dataColumn AutoIncrementSeed=0 and AutoIncrementStep=1 each time i append a new master row, but it seem not work, it still remain
1
7851
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..
0
944
by: SWIL | last post by:
Hi, I made my own datacolumn Class which inherits from Data.DataColumn. To this class I have added 2 properties. To add datacolumn created through my new class I have to call.. DataSet.Table.Column.Add method which is a part of datacolumncollection , where the defined data column type is Data.DataColumn and not my custom column. Thus I have no method to access my datacolumn properties through dataset.
4
2453
by: Tim | last post by:
Hello All, I could use some help on an error that is just now popping it's head up. Seems that the autoincrement numeric has hit 32,767. The autoincrement is used in various locations in the database, but in this case (log sheets), we have hit 32k log entries over the past 2 years. Is there a simple switch to set the autoincrement from integer to long integer?
0
1654
by: Ryan Liu | last post by:
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 NullReferenceException? dcLineId = new DataColumn(LINEID_STR,
0
9519
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
10215
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...
1
10165
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
10001
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
6783
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
5437
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...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.