473,414 Members | 1,621 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,414 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 1261
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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,...
0
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...

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.