473,394 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Datatype declaration for Add New in Datagrid

I have a datagrid that is and edit,update and add etc... and everything works in it fine except for add new. It craps out on the add new of my ContactID Field. This is a integer field and is also an Identity field in the database (SQL2000)
If I declare the ContactID field as text it fails (obviously) but when I delcare it as Integer it tells bombs and tells me it is expecting a int32 instead of what I have. Here is the declaration

Dim ContactID As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Tex

Anyway I guess the question is how do I declare field that is an Identity field in SQL to work on my add new link from datagrid?

btw I am a newb to this so sorry if this is a basic question I cant seem to find the answer in my books or in the help files
Jul 21 '05 #1
2 1260
Set the Autoincrement propety of the datacolumn to true. Then set the
Autoincrement seed as 0 and the Autoincrement value to -1. This way,
when -1 hits the db, SQL Server will asssign the next legit value and
guarantee that you and some other user don't step on each other.

Also, are you using a Binding Context?
http://www.knowdotnet.com/articles/adopartiii.html

"JonnyFrag" <an*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
I have a datagrid that is and edit,update and add etc... and everything works in it fine except for add new. It craps out on the add new of my
ContactID Field. This is a integer field and is also an Identity field in
the database (SQL2000) If I declare the ContactID field as text it fails (obviously) but when I delcare it as Integer it tells bombs and tells me it is expecting a int32
instead of what I have. Here is the declaration:
Dim ContactID As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Anyway I guess the question is how do I declare field that is an Identity field in SQL to work on my add new link from datagrid?
btw I am a newb to this so sorry if this is a basic question I cant seem

to find the answer in my books or in the help files
Jul 21 '05 #2
Set the Autoincrement propety of the datacolumn to true. Then set the
Autoincrement seed as 0 and the Autoincrement value to -1. This way,
when -1 hits the db, SQL Server will asssign the next legit value and
guarantee that you and some other user don't step on each other.

Also, are you using a Binding Context?
http://www.knowdotnet.com/articles/adopartiii.html

"JonnyFrag" <an*******@discussions.microsoft.com> wrote in message
news:91**********************************@microsof t.com...
I have a datagrid that is and edit,update and add etc... and everything works in it fine except for add new. It craps out on the add new of my
ContactID Field. This is a integer field and is also an Identity field in
the database (SQL2000) If I declare the ContactID field as text it fails (obviously) but when I delcare it as Integer it tells bombs and tells me it is expecting a int32
instead of what I have. Here is the declaration:
Dim ContactID As Integer = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Anyway I guess the question is how do I declare field that is an Identity field in SQL to work on my add new link from datagrid?
btw I am a newb to this so sorry if this is a basic question I cant seem

to find the answer in my books or in the help files
Jul 21 '05 #3

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

Similar topics

2
by: David Slinn | last post by:
I have created a simple XML document, generated a schema from it (which Visual Studio makes everything a string element). I then went through and changed all fields that are dates to the Date data...
2
by: JonnyFrag | last post by:
I have a datagrid that is and edit,update and add etc... and everything works in it fine except for add new. It craps out on the add new of my ContactID Field. This is a integer field and is also an...
0
by: JonnyFrag | last post by:
I have a datagrid that is and edit,update and add etc... and everything works in it fine except for add new. It craps out on the add new of my ContactID Field. This is a integer field and is also an...
0
by: vijayalakshmi.venkataraman | last post by:
Hello, I have a .NET client that accesses a Java webservice. Let me first say that the client stub I got generated from the wsdl was incomplete and had to make changes to it manually to make it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
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...

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.