Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add record through ASP to SQL DB and Autonumbering 1

Status
Not open for further replies.

BonitaRobinson

IS-IT--Management
Jun 3, 2002
6
US
I have an employee db.When table was first setup, I was using SSN as the primary key. I wanted to remove the SSN and replace with auto number field.When table was using SSN I could add and remove records to the db with no problem. Now when I add a record through the asp page, I get the following error:

Cannot update the database
Error Description: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'anum', table 'CCSDirectory.dbo.EmpInfo'; column does not allow nulls. INSERT fails.
Error Number: -2147467259
Error Source: Microsoft OLE DB Provider for ODBC Drivers


The auto number field properties are:
anum - numeric - 9 - no nulls

When I change to allow nulls, it doesn't number. It puts NULL in the column.

Help! [bigears]
 
Hi,

I think in the SQL to insert u r specifying the autonumber field also... i think it will work if u remove the identity field from the insert SQL... that is just specify rest of the fields leave the identity field..... SQL server will handle it...

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top