Insert into SQL Server issue

J

JP SIngh

I am having problems inserting data into a simple table

Insert into Forums (Title, PageUrl, ContractId) Values ('54249',
'test01.asp',54249)
Microsoft OLE DB Provider for SQL Server error '80040e2f'

Cannot insert the value NULL into column 'ForumID', table
'LegalOnline.dbo.Forums'; column does not allow nulls. INSERT fails.

/sqllegal/submitcontract.asp, line 214

My table structure is below

ForumId Int 4 (identity column)

Title nvarchar 50

PageUrl nvarchar 250

contractid numeric 9(10,0)

if i copy and paste the above query in sql query analyzer and run it it
works perfectly but not through asp code.



can someone help



thanks
 
B

Bob Barrows [MVP]

JP said:
I am having problems inserting data into a simple table

Insert into Forums (Title, PageUrl, ContractId) Values ('54249',
'test01.asp',54249)
Microsoft OLE DB Provider for SQL Server error '80040e2f'

Cannot insert the value NULL into column 'ForumID', table
'LegalOnline.dbo.Forums'; column does not allow nulls. INSERT fails.

The error message implies that the ForumID column is not an identity column.
Use Profiler to trace what is actually being executed on the SQL Server when
the error is generated..
My table structure is below

ForumId Int 4 (identity column)

Title nvarchar 50

PageUrl nvarchar 250

contractid numeric 9(10,0)

This does not help. If Profiler does not provide your solution, in
Enterprise Manager, right-click your table and select All Tasks / Generate
SQL Script and show us the generated script.
We will also need to see the code used to run the INSERT.

Bob Barrows
 
A

Al

It looks like ForumID is not an Identity Column

Try this then.
Insert into Forums (ForumID, Title, PageUrl, ContractId)
Values (1,'54249','test01.asp',54249)

Good Luck.!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top