Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:10:01+00:00 2026-05-26T08:10:01+00:00

I have columns in my database called ModifyUser and ModifyDate that are supposed to

  • 0

I have columns in my database called ModifyUser and ModifyDate that are supposed to show the username and date and time of the last person that has updated a specific product somehow.

I thought if I just added the second query then I would be fine, but for some reason the application wants to add ProductName into the Product table too. Why isn’t the application just inserting the 2 values I told it to insert in the Product table INSERT?

Error message: Cannot insert the value NULL into column 'ProductName', table
'Products.dbo.Product'; column does not allow nulls. INSERT fails.
The statement has been terminated.

'SQL INSERT: CompanyLink Table
        Dim strSQL As String = "INSERT INTO CompanyLink (ProductID, CompanyID) 
        VALUES (@ProductID, @CompanyID);INSERT INTO Product (ModifyDate, ModifyUser)
        VALUES (getdate(), @ModifyUser)"

    Using cn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)

    Using cmd As New SqlCommand(strSQL, cn)

    cmd.Parameters.Add(New SqlParameter("@ProductID", ProductID.Value))
    cmd.Parameters.Add(New SqlParameter("@CompanyID", company.Value))
    cmd.Parameters.Add(New SqlParameter("@ModifyUser",
    System.Web.HttpContext.Current.User.Identity.Name))

    cn.Open()
    cmd.ExecuteNonQuery()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:10:02+00:00Added an answer on May 26, 2026 at 8:10 am

    The error message is pretty clear: your are not providing ProductName, which is a required (NOT NULL) field.

    In order to fix it, you have to provide the ProductName, modifying this:

    INSERT INTO Product (ModifyDate, ModifyUser, ProductName)
        VALUES (getdate(), @ModifyUser, @ProductName)
    

    and add this:

    cmd.Parameters.Add(New SqlParameter("@ProductName", SomeVariableContainingProductName))
    

    Update

    Since what you really need is an update, your statement will be:

    Update product
    set ModifyDate = getdate(),
        ModifyUser = @ModifyUser
    where ProductID = @ProductID
    

    Remember to provide all parameters values for the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table called users This table has two columns (that are
I have a Rails model called Person which has database table columns for first_name
I have a database that has four columns like this level_1, level_2, level_3, level_4
I have a Postgre database that has say 10 columns. The fifth column is
Ok... I have a database table called employees.. This has columns called ID, Name,
I have a database table has four columns called Courses(CourseID,CourseName,CreditHours,LabSession) , and I wanna
In my oracle database I have table called PERSON with columns code, surname, forename.
Let's say I have a table in my database called Orders that has the
In mysql database i have this column called: Name: Date Type: datetime I have
I'm new to database indexing, if I have 2 columns in a table that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.