Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 25th, 2004, 05:15 AM
stevie17 stevie17 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 59 stevie17 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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

Reply With Quote
  #2  
Old March 25th, 2004, 06:27 AM
Kris_Vanherck's Avatar
Kris_Vanherck Kris_Vanherck is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Belgium, Antwerp
Posts: 177 Kris_Vanherck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 sec
Reputation Power: 5
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)

Reply With Quote
  #3  
Old April 6th, 2004, 11:57 AM
spungebob spungebob is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Dover
Posts: 128 spungebob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 39 sec
Reputation Power: 5
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

Reply With Quote
  #4  
Old April 6th, 2004, 12:09 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
You could also use the UniqueIdentifier data type.

Reply With Quote
  #5  
Old April 16th, 2004, 12:20 AM
imughal imughal is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 6 imughal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 42 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Data Type int and AutoNumber


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT