473,491 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1262
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
1875
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
277
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
271
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
1625
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
7115
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
7190
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...
1
6858
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...
0
5451
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,...
1
4881
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...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
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 ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
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...

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.