Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - OleDb Error: No value for required para
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

OleDb Error: No value for required para

 Post Reply Post Reply
Author
chuksted View Drop Down
Newbie
Newbie


Joined: 20 January 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote chuksted Quote  Post ReplyReply Direct Link To This Post Topic: OleDb Error: No value for required para
    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#
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
chuksted View Drop Down
Newbie
Newbie


Joined: 20 January 2005
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote chuksted Quote  Post ReplyReply Direct Link To This Post 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#?

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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


Edited by Mart - 11 May 2005 at 2:43am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.