Print Page | Close Window

OleDb Error: No value for required para

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=15017
Printed Date: 29 March 2026 at 12:03pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: OleDb Error: No value for required para
Posted By: chuksted
Subject: OleDb Error: No value for required para
Date Posted: 10 May 2005 at 5:50pm
I get this error:
Error occurred, customer data could not be updated: No value given for one or more required parameters.
What have I not done right?

Here is the code:
        private void btnCapUpdate_Click(object sender, System.EventArgs e)
        {
        // Set up variables
            double d1, d2, d3, d4, d5, d6, sum1, sum2, sum3, sum4, sum5;
           
        //Get the selected company name from combobox and assign to variable
            string strCoyName = selCompany.SelectedItem.ToString();
       
        // Convert textbox values to double and assign to variables
            d1 = Convert.ToDouble(txtStckQty.Text);
            d2 = Convert.ToDouble(txtStckPrice.Text);
            d3 = Convert.ToDouble(txtBondQty.Text);
            d4 = Convert.ToDouble(txtBondPrice.Text);
            d5 = Convert.ToDouble(txtPrefStckQty.Text );
            d6 = Convert.ToDouble(txtPrefStckPrice.Text);

        // Do the calculation
            sum1 = d1 * d2;
            sum2 = d3 * d4;
            sum3 = d5 * d6;
            sum4 = sum2 + sum3;
            sum5 = sum1 + sum4;

        // Convert back to string and display in text boxes
            txtStckMktVal.Text = Convert.ToString(sum1);
            txtBondValue.Text = Convert.ToString(sum2);
            txtPrefStckValue.Text = Convert.ToString(sum3);
            txtOtherIssuesVal.Text = Convert.ToString(sum4);
            txtTotalCap.Text = Convert.ToString(sum5);

        // Set up DB connection parameters and open it
            OleDbCommand myOleDbCommand = new OleDbCommand();
            myOleDbConn.Open();
            myOleDbCommand.Connection = myOleDbConn;
       
        // Update DB with new figures from calculation
                myOleDbCommand.CommandText = "UPDATE CapitalizationTbl SET capComStckQty = '" + d1
                    + "', capComStckPrice ='"+d2+"', capComMktValue ='"+sum1+"', capBondQty ='"+d3
                    +"', capBondPrice ='"+d4+"', capBondValue ='"+sum2+"', capPrefQty ='"+d5
                    +"', capPrefPrice ='"+d6+"', capPrefVal ='"+sum3+"', capOtherVal ='"+sum4
                    +"', capGrandTotal ='"+sum5+"' WHERE coyName = '"+strCoyName+"'";
            try
            {
                myOleDbCommand.ExecuteNonQuery();
                MessageBox.Show("Customer data updated!");
            }

        // Catch any errors

            catch(OleDbException ex)
            {
                MessageBox.Show("Error occurred, customer data could not be updated:" + ex.Message);
            }

            finally
            {
        //Close the connection if it is open
                if (myOleDbConn.State==ConnectionState.Open)
                {
                    myOleDbConn.Close();
                }
            }

        }
Please help me somebody. I have tried all I know; I am new to C#


-------------
Chuksted2003



Replies:
Posted By: Gullanian
Date Posted: 10 May 2005 at 7:49pm
One of the values you are entering into the DB doesn't contain a value

Response.write strSQL before execution to see which one.


Posted By: chuksted
Date Posted: 10 May 2005 at 11:37pm
It appears I cannot use Response.Write in C#. How do you print out a set of viables or values in C#?



-------------
Chuksted2003


Posted By: Mart
Date Posted: 11 May 2005 at 2:42am
You can use response.write it's just:

string val = "Hello World";
Response.Write(val);

If you can't get that to work use

System.Diagnostics.Debug.Write(val);

and start the project in debug mode through VS.NET and look in the output pane



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net