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 8599517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:24:52+00:00 2026-06-12T01:24:52+00:00

I have created a parameterized SQL insert query and I have made a mistake

  • 0

I have created a parameterized SQL insert query and I have made a mistake somewhere. I kept getting a message that values would be truncated, so, during troubleshooting I reduced the query to only fields that required values (NULLs not allowed), and the insert statement completed.

I check the table, and I see my parameter names inserted, not the values they should be pulling from the form’s textboxes.

Obviously I am calling my parameters incorrectly but I just can’t figure out where I have gone wrong. I am hoping you all can help me.

Thanks in advance!

NOTE: Yes, I know there are more parameters than what I am using in the INSERT string. I have intentionally cut down the values used for troubleshooting.

Thanks again!

try {
    string InsertString = @"INSERT INTO Item.Itemtable
        (ItemNumber, ItemDesc, RatioToOriginalItemNumber, OriginalItemNumber, EntreeCount, ItemType, ProteinBeverage)
        Values(@ItemNumberValue, '@ItemDescValue', @RatioToOriginalItemNumberValue, @OriginalItemNumberValue, @EntreeCountValue, '@ItemTypeValue', @ProteinBeverageValue)";
    SqlCommand InsertNewItem = new SqlCommand(InsertString, PmixWriter);
    //Define Insert Parameters
    SqlParameter @ItemNumberValue = InsertNewItem.Parameters.Add("@ItemNumberValue", System.Data.SqlDbType.Int);
    SqlParameter @ItemDescValue = InsertNewItem.Parameters.Add("@ItemDescValue", System.Data.SqlDbType.VarChar, 100);
    SqlParameter @ItemTypeValue = InsertNewItem.Parameters.Add("@ItemTypeValue", System.Data.SqlDbType.VarChar, 100);
    SqlParameter @ProteinBeverageValue = InsertNewItem.Parameters.Add("@ProteinBeverageValue", System.Data.SqlDbType.VarChar, 100);
    SqlParameter @IsCouponValue = InsertNewItem.Parameters.Add("@IsCouponValue", System.Data.SqlDbType.Char, 3);
    SqlParameter @EntreeCountValue = InsertNewItem.Parameters.Add("@EntreeCountValue", System.Data.SqlDbType.Real);
    SqlParameter @BevCountValue = InsertNewItem.Parameters.Add("@BevCountValue", System.Data.SqlDbType.TinyInt);
    SqlParameter @OriginalItemNumberValue = InsertNewItem.Parameters.Add("@OriginalItemNumberValue", System.Data.SqlDbType.Int);
    SqlParameter @RatioToOriginalItemNumberValue = InsertNewItem.Parameters.Add("@RatioToOriginalItemNumberValue", System.Data.SqlDbType.TinyInt);
    SqlParameter @FPBeverageCountValue = InsertNewItem.Parameters.Add("@FPBeverageCountValue", System.Data.SqlDbType.Int);
    SqlParameter @FPBeverageEntreeCountValue = InsertNewItem.Parameters.Add("@FPBeverageEntreeCountValue", System.Data.SqlDbType.Int);
    SqlParameter @FoodCostValue = InsertNewItem.Parameters.Add("@FoodCostValue", System.Data.SqlDbType.Money);

    //Assign and covert values to the stated SQL parameters.
    @ItemNumberValue.Value = Convert.ToInt32(ItemNumberBox.Text);
    @ItemDescValue.Value = ItemDescBox.Text;
    @ItemTypeValue.Value = ItemTypeBox.Text;
    @ProteinBeverageValue.Value = ProteinBevBox.Text;
    @IsCouponValue.Value = IsCouponBox.Text;
    @EntreeCountValue.Value = Convert.ToInt32(EntreeCountBox.Text);
    @BevCountValue.Value = Convert.ToInt32(BevCountBox.Text);
    @OriginalItemNumberValue.Value = Convert.ToInt32(OriginalItemNumBox.Text);
    @RatioToOriginalItemNumberValue.Value = Convert.ToInt32(RatioBox.Text);
    @FPBeverageCountValue.Value = Convert.ToInt32(FPBevBox.Text);
    @FPBeverageEntreeCountValue.Value = Convert.ToInt32(FPBevEntreeBox.Text);
    @FoodCostValue.Value = Convert.ToDecimal(0.00);

    InsertNewItem.ExecuteNonQuery();
} catch (SqlException) {
    throw;   
}
  • 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-06-12T01:24:53+00:00Added an answer on June 12, 2026 at 1:24 am

    In your INSERT statement, remove the single quotes from @ItemDescValue and @ItemTypeValue parameters. They are currently being inserted as literal values otherwise.

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

Sidebar

Related Questions

I have a parameterized SQL query targetted for SQL2005 which is dynamically created in
I have created some JQuery that will expand a div 'popup' on hover and
I have created an android application that calls (using kSOAP library) a SOAP based
I have created a function that shows/hides different messages according to a combination of
I have created a dialog and got a problem that only part of the
I have created the query listed below. It works when I run it. string
I have a parameterized query and it was working fine, but when I delete
I have this parameterized query in an Npgsqlcommand: UPDATE raw.geocoding SET the_geom = ST_Transform(ST_GeomFromText('POINT(:longitude
I have a crystal report with a bunch of parameterized fields that are being
I have an SQL Azure database with a table that has JobId primary key.

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.