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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:48:11+00:00 2026-06-15T07:48:11+00:00

I am stuck looking and debugging this code and I can’t see any errors.

  • 0

I am stuck looking and debugging this code and I can’t see any errors. The error at the moment is No Value given for one or more required Parameters

The only column that is required is prodName and that is always checked to make sure the string is not empty, otherwise could it be the length parameters of my integer and currency values? I’m just trying to make them as large as possible to accept most reasonable sized data fields.

I’m also worried that my boolean does not fit the “is null, is not null” categories, but will return false if the checkbox is unclicked for it.

Here’s my params, I would greatly appreciated if you guys looked over it briefly for syntax or logic errors i could have made, I am rather intermediate at c#

public int updateProducts(int prodId, string productName, string supplier, string category, string quantityPerUnit, string unitPrice, string unitsInStock, string unitsOnOrder, string reorderLevel, bool discontinued)
{
    int rows = 0;
    int PId = prodId;
    string prodName = productName;
    int supp = int.Parse(supplier);
    int? categoryID = 0;
    string qPerUnit = quantityPerUnit;
    Decimal? uPrice = 0;
    int? uInStock = 0;
    int? uOnOrder = 0;
    int? reorderLvl = 0;
    bool disc = discontinued;
    if (!string.IsNullOrWhiteSpace(unitPrice))
    {
        uPrice = Decimal.Parse(unitPrice);
    }
    if (!string.IsNullOrWhiteSpace(category))
    {
        categoryID = int.Parse(category);
    }
    if (!string.IsNullOrWhiteSpace(unitsInStock))
    {
        uInStock = int.Parse(unitsInStock);
    }
    if (!string.IsNullOrWhiteSpace(unitsOnOrder))
    {
        uOnOrder = int.Parse(unitsOnOrder);
    }
    if (!string.IsNullOrWhiteSpace(reorderLevel))
    {
        reorderLvl = int.Parse(reorderLevel);
    }

    string dbString = "UPDATE [Products] SET [ProductName]= ?,[Supplier]= ?,[Category]= ?,[QuantityPerUnit]= ?,[UnitPrice]= ?,[UnitsInStock]= ?,[UnitsOnOrder]= ?,[ReorderLevel]= ?, [Discontinued]= ? WHERE [SupplierID]= " + PId;

    try
    {
        conn.Open();
        oleCommand = new OleDbCommand(dbString, conn);

        oleCommand.Parameters.Add(new OleDbParameter("@prodName", OleDbType.VarChar, 30, ParameterDirection.Input, false, 10, 0, "ProductName", DataRowVersion.Original, null)).Value = prodName;
        oleCommand.Parameters.Add(new OleDbParameter("@supp", OleDbType.Integer, 40, ParameterDirection.Input, false, 10, 0, "Supplier", DataRowVersion.Original, null)).Value = supp;
        oleCommand.Parameters.Add(new OleDbParameter("@cat", OleDbType.Integer, 30, ParameterDirection.Input, true, 10, 0, "Category", DataRowVersion.Original, null)).Value = categoryID.HasValue ? (object)categoryID : DBNull.Value;
        oleCommand.Parameters.Add(new OleDbParameter("@qPU", OleDbType.VarChar, 20, ParameterDirection.Input, true, 10, 0, "QuantityPerUnit", DataRowVersion.Original, null)).Value = string.IsNullOrWhiteSpace(qPerUnit) ? DBNull.Value : (object)qPerUnit;
        oleCommand.Parameters.Add(new OleDbParameter("@uPrice", OleDbType.Currency, 6, ParameterDirection.Input, true, 10, 0, "UnitPrice", DataRowVersion.Original, null)).Value = uPrice.HasValue ? (object)uPrice : DBNull.Value;
        oleCommand.Parameters.Add(new OleDbParameter("@uInStock", OleDbType.Integer, 50, ParameterDirection.Input, true, 10, 0, "UnitsInStock", DataRowVersion.Original, null)).Value = uInStock.HasValue ? (object)uPrice : DBNull.Value;
        oleCommand.Parameters.Add(new OleDbParameter("@uOnOrder", OleDbType.Integer, 50, ParameterDirection.Input, true, 10, 0, "UnitsOnOrder", DataRowVersion.Original, null)).Value = uOnOrder.HasValue ? (object)uOnOrder : DBNull.Value;
        oleCommand.Parameters.Add(new OleDbParameter("@reorderLvl", OleDbType.Integer, 50, ParameterDirection.Input, true, 10, 10, "ReorderLevel", DataRowVersion.Original, null)).Value = reorderLvl.HasValue ? (object)reorderLvl : DBNull.Value;
        oleCommand.Parameters.Add(new OleDbParameter("@discontinued", OleDbType.Boolean, 10, ParameterDirection.Input, true, 10, 0, "Discontinued", DataRowVersion.Original, null)).Value = disc;
        rows = (int)oleCommand.ExecuteNonQuery();

    }
    catch (Exception ex)
    {
        dbError = "Add Supplier command Error: " + ex.Message;
    }
    finally
    {

        conn.Close();
    }
    return rows;
}
  • 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-15T07:48:12+00:00Added an answer on June 15, 2026 at 7:48 am

    It’s the square brackets. Square brackets means Parameter to Jet Sql. But it also means “this identifier has a space in it”

    None of your identifiers have spaces, so just remove the square brackets. If you did have an identifier with a space, you have to fully qualify the name.

    Ref: JET SQL for Access 2003

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

Sidebar

Related Questions

(Don't know if this is strictly on-topic, but I don't see any better Stack
Hey so following this Question I've gotten stuck again, and yeah I've tried looking
I am looking for tips on how to aid my debugging by adding code
Looking for tools for debugging n3. Are we stuck with using XML just because
I'm really stuck here. Im having an array looking like this below. And now
I need to get something like this: But I've been stuck looking for a
I get stuck sometimes with very long clauses and I am looking for a
I am looking for a RPC stack that can be used between a Java
I was looking at stockcharts - http://code.google.com/p/stock-chart for creating candlestickgraphs in my application. I
I have been looking for an answer to this on Stack Overflow, but I

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.