|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Data Type int and AutoNumber
In SQL Server I am creating a table for a database and I have two fields Type and Description. The Type field is an 'int' datatype and is the primary key. I am writing asp code to add a row to the database using the details from a textbox on a web form. I only want to have to enter information in one textbox for the description field to add this record however as the Type field is a primary key it won't allow me to do this. Is there any way of making the Type field an 'int' datatype as well as having it as an AutoNumber.Can someone tell me how to do this
|
|
#2
|
||||
|
||||
|
autonumber in sql server is the identity property
set it to yes the seed property is the initial start (the first key), put this number above the value of your highest current value if you already have data in the table) |
|
#3
|
|||
|
|||
|
Question: is the field called "Type" and is this your Identity field with type [int]
If this is the Identity field then you don't need to place a value in this field. It is automatic and populates after the reports is written. if you need to update the records after you
insert a record you would be best to use a stored procedure call that can return the @@identity variable/variant which would contain the newid()/sequence number/identity. Bob@lyrex.com |
|
#4
|
||||
|
||||
|
You could also use the UniqueIdentifier data type.
|
|
#5
|
|||
|
|||
|
auto increment problem
i have id with int data type that is auto number, it working fine at my local system but when i upload file and try to add record it not accepting and not incrementing the auto number, the error message says id is required and you can not add value.
irfan |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Data Type int and AutoNumber |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|