none
Parameter value is out of range RRS feed

  • Question

  • i'm working on my own project witch includes a database. So i made in a form the textboxes to fill in that then could be saved to the database. Now the problem is that i always get the same error no mather what i change. So the value i wan't to enter is "20,0" and the data type is set as numeric(2,1) i even tried decimal(10,1) but also that didn't work, so now i am stuck and don't know what to do! 

    • Moved by Bob Beauchemin Tuesday, August 4, 2015 10:09 PM Moved to the forum for client-side SqlClient issues for best results
    Tuesday, August 4, 2015 8:45 PM

Answers

  • OK, the problem is the precision and scale properties in the parameter of the TableAdapter. Actually, the scale is OK (it is 1 and you only have 1 decimal place). However, the precision should be 3 (2 places to the left of the decimal point plus 1 to the right).

    You can fix that in the properties of the TableAdapter. You can read the thread in this link if you want to: http://forums.asp.net/t/1123922.aspx?inserting+a+decimal+number+from+net+to+stored+proc+with+decimal+parameter

    But, I'll summarize how to fix it:

    1. Right click on the TableAdapter, and select Properties from the context menu.
    2. Find the command where your stored procedure is used. For example, UpdateCommand, just expand UpdateCommand.
    3. Click ... on Parameters to activate the Paramters Collection Editor.
    4. Select the parameter from left and you will see Precision and Scale on the right.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by dewestvlaming Sunday, August 9, 2015 1:36 AM
    Saturday, August 8, 2015 3:54 PM

All replies

  • ps the error i get: "Parameter value "20,0" is out of range
    Tuesday, August 4, 2015 8:46 PM
  • You would need to create your column as numeric(3,1), since you're trying to store three digits, one being used after the decimal.
    Tuesday, August 4, 2015 8:57 PM
  • well i tried it but it still doesn't work 
    Tuesday, August 4, 2015 9:24 PM
  • Could you show us the code you are using to do the database update?

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Wednesday, August 5, 2015 4:57 AM
  • really isn't that much of code. I got to admit i was i bit lazy and let visual studio do the work for me :p

     Private Sub StrainsBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles StrainsBindingNavigatorSaveItem.Click

            Me.Validate()

            Me.StrainsBindingSource.EndEdit()

            Me.TableAdapterManager.UpdateAll(Me.AddStrainDS)

    Wednesday, August 5, 2015 8:47 AM
  • Unfortunately, that's not going to help much. So, let's try this.

    First, what is your database (SQL Server, Access, MySql ... )?

    Show us the actual database definition of the columns you're having trouble with.

    Show us the actual DataSet/DataTable definition of the columns you're having trouble with (preferably from the .xsd).


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Wednesday, August 5, 2015 3:57 PM
  • well it's a local sql database.

    so the value i wan't to enter has 3 digits one behind the comma 

    [Temperatuur Min. stekje]     NUMERIC (3, 1) NOT NULL,

    Wednesday, August 5, 2015 5:35 PM
  • And how is it defined in your AddStrainDS? (post the column definition from the .xsd)

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Wednesday, August 5, 2015 7:58 PM

  • <Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Decimal" Direction="Input" ParameterName="@p18" Precision="2" ProviderType="Decimal" Scale="1" Size="0" SourceColumn="Temperatuur Min. Groei" SourceColumnNullMapping="false" SourceVersion="Original" />

    Saturday, August 8, 2015 9:57 AM
  • OK, the problem is the precision and scale properties in the parameter of the TableAdapter. Actually, the scale is OK (it is 1 and you only have 1 decimal place). However, the precision should be 3 (2 places to the left of the decimal point plus 1 to the right).

    You can fix that in the properties of the TableAdapter. You can read the thread in this link if you want to: http://forums.asp.net/t/1123922.aspx?inserting+a+decimal+number+from+net+to+stored+proc+with+decimal+parameter

    But, I'll summarize how to fix it:

    1. Right click on the TableAdapter, and select Properties from the context menu.
    2. Find the command where your stored procedure is used. For example, UpdateCommand, just expand UpdateCommand.
    3. Click ... on Parameters to activate the Paramters Collection Editor.
    4. Select the parameter from left and you will see Precision and Scale on the right.


    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    • Marked as answer by dewestvlaming Sunday, August 9, 2015 1:36 AM
    Saturday, August 8, 2015 3:54 PM
  • thank you so much c: 
    Sunday, August 9, 2015 1:36 AM
  • You're welcome! Glad I could help!  =0)

    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Sunday, August 9, 2015 4:40 AM