Insert into SQL Server issue

Discussion in 'ASP General' started by JP SIngh, Jun 2, 2005.

  1. JP SIngh

    JP SIngh Guest

    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
     
    JP SIngh, Jun 2, 2005
    #1
    1. Advertising

  2. JP SIngh wrote:
    > 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
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jun 2, 2005
    #2
    1. Advertising

  3. JP SIngh

    Al Guest

    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.!


    "JP SIngh" <> wrote in message
    news:...
    >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
    >
    >
    >
    >
     
    Al, Jun 2, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike John
    Replies:
    1
    Views:
    424
    Rocky Moore
    Nov 14, 2003
  2. Kevin Lawrence

    Storing binary into SQL Server in INSERT string

    Kevin Lawrence, Feb 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    667
    Kevin Lawrence
    Feb 3, 2006
  3. Harry Zoroc
    Replies:
    1
    Views:
    946
    Gregory Vaughan
    Jul 12, 2004
  4. Replies:
    5
    Views:
    576
    Egbert Nierop \(MVP for IIS\)
    Mar 15, 2006
  5. Sergio del Amo
    Replies:
    4
    Views:
    238
Loading...

Share This Page