none
Trouble converting string to decimal RRS feed

  • Question

  • I have a form and an SQL Server database. The form has a TextBox control used for money exclusively, like 2,000.00 or so. The form is generated by a C# program. At one point I need to save this amount in an Sql table/field. That field is Decimal (10,2).

    If I use construction like the following I get a runtime error:

    cmdm = SetControls.createSqlParameter(cmdm, "amount", tBoxPaymentAmount_pg5.Text.Trim());

    If I try to convert string to decimal like this:

    cmdm = SetControls.createSqlParameter(cmdm, "amount", Convert.ToDecimal (tBoxPaymentAmount_pg5.Text.Trim()));

    I get in trouble at compilation time. The message's universally the same: Cannot convert from string to decimal or even vice versa for some reason, although I am not even attempting a reverse conversion.

    There must be a standard way to do it but I cannot find any suitable control or find a way of conversion.

    Thanks, - MyCatAlex



    • Edited by MyCatAlex Friday, October 12, 2018 6:48 PM
    Friday, October 12, 2018 6:45 PM

Answers


  • So, you want me to use this method. 


    No. You're missing the significant part of the code examples I posted.
    Forget about everything except:

    The fact that the method has overloads.

    The defined parameters/arguments.

    What I said about the exception that you're seeing applies to any and all
    methods with overloads.

    I'm suggesting that in your code you appear (based on results) to have
    overloads of your method which take different parameter types. So passing
    for example a string as the 3rd argument would work because there exists
    an overload that takes a string as the 3rd argument.

    Similarly there appears to be an overload that takes a DateTime as the
    3rd parameter so calling the method with a DateTime object as the 3rd
    argument will work.

    However the results you are seeing suggest that you do not have an overload
    of your method which takes a Decimal as the 3rd parameter. So calling your
    method while passing a Decimal object as the 3rd argument will fail because
    the compiler cannot find an overload of your method which matches.

    These results suggest that you need to add an overload of your method
    which *does* accept a Decimal as an argument.

    Internally this overload will probably be very similar to the existing
    overloads, except perhaps for the use of the SqlDbType enum. In the case
    of an overload with a Decimal argument, you would likely need to use
    SqlDbType.Decimal whereas the other overloads are probably using
    SqlDbType.VarChar or SqlDbType.DateTime

    - Wayne

    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Saturday, October 13, 2018 7:56 PM
  • >>I posted about 30 lines of my code above with SetControls.createSqlParameter().<<

    Yes, you posted how you called that method. But I asked about posting the actual code for the static createSqlParameter() method. I Googled and I can't find a relevant SetControls class anywhere. But, I don't know everything, perhaps it's part of a .NET namespace that I'm not familiar with. Sounds like Wayne isn't familiar with it either.

    >>but practically, how can I add an overload to the method defined by Microsoft<<

    As I hinted at above, I don't know if that's .NET Framework code. Have you've got a class defined in your application named SetControls that has a static method named createSqlParameter()? Or maybe you're using some 3rd-party assemblies? What namespace is this SetControls class in?


    ~~Bonnie DeWitt [C# MVP]

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

    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Saturday, October 13, 2018 9:19 PM
    Moderator

  •  I asked about posting the actual code for the static createSqlParameter() method. I Googled and I can't find a relevant SetControls class anywhere. But, I don't know everything, perhaps it's part of a .NET namespace that I'm not familiar with. Sounds like Wayne isn't familiar with it either.

    Right. The only example I've seen so far of its use is in a ten-year old thread:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/fce68761-5ed1-43fd-9fc1-8e1af1e84605/the-sqlparametercollection-only-accepts-nonnull-sqlparameter-type-objects-not-sqlparameter

    Note the code in the post by AlexBB showing overloads.

    Those examples also illustrate what I was referring to in my last post
    about the use of the SqlDbType enum.

    - Wayne

    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Saturday, October 13, 2018 9:33 PM
  •  how can I add an overload to the method defined by Microsoft? All overloads are in System.Data.SqlTypes namespace I presume.


    Not for that method, AFAIK. Reference here:

    System.Data.SqlTypes Namespace
    https://docs.microsoft.com/en-us/dotnet/api/system.data.sqltypes?view=netframework-4.7.2

    I think you should highlight (select) SetControls.createSqlParameter in
    the IDE editor. Then right-click the mouse and from the menu select either

    Go To Definition

    or

    Go To Implementation

    See where it takes you.

    - Wayne


    • Edited by WayneAKing Sunday, October 14, 2018 4:19 AM
    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Sunday, October 14, 2018 4:18 AM

All replies

  • Try Decimal.Parse

    cmdm = SetControls.createSqlParameter(cmdm, "amount", Decimal.Parse(tBoxPaymentAmount_pg5.Text.Trim()));

    or

    cmdm = SetControls.createSqlParameter(cmdm, "amount", Decimal.Parse(tBoxPaymentAmount_pg5.Text.Trim(), CultureInfo.InvariantCulture));


    Thanks, AT

    Friday, October 12, 2018 6:59 PM
  • Hi,

    maybe you have to change the culture:

                var cultureInfo = new CultureInfo("en-US");
                cultureInfo.NumberFormat.CurrencyDecimalSeparator = ".";
                cultureInfo.NumberFormat.CurrencyGroupSeparator = ",";
                Thread.CurrentThread.CurrentCulture = cultureInfo;

    Greetings, Chris

    Friday, October 12, 2018 7:42 PM
  • But when creating CultureInfo with en-US, it should already have "." and "," set correctly. So this should be enough:

    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

    I hope it works.

    Greetings, Chris

    Friday, October 12, 2018 7:49 PM
  • Sorry for answering haphazardly but I tried Decimal.Parse and it gave me a compile error, so I could not even run it. Unless I made a mistake somewhere? I also tried "invariantCulture." That did not work either. There should be s sure way to do it. Where is it?

    Thanks, - MyCatAlex

    Friday, October 12, 2018 9:20 PM
  • OK, this is what I just did and I need an explanation why the system behaves this way:

    string result = tBoxPaymentAmount_pg5.Text.Trim();
    Decimal res = Convert.ToDecimal(result);

    Then, after some lines:

    cmdm = SetControls.createSqlParameter(cmdm, "amount", res);

    I get this bizarre COMPILE error, even before I try compilation:

    "The argument cannot convert from Decimal to String. ????

    "amount" is not a string, It is Decimal. Why does it make such a strange assumption? The first two lines work fine, no problem.

    Does anybody know why it happens?

    Thanks, - MyCatAlex

    Friday, October 12, 2018 9:59 PM
  •  I tried Decimal.Parse and it gave me a compile error, so I could not even run it.

    I also tried "invariantCulture." That did not work either. 

    As always, if you want assistance with a compile error you have to show

    The actual error message (copy & paste)

    The exact code that caused the error (copy & paste)

    >That did not work either.

    Be specific.

    - Wayne

    Friday, October 12, 2018 10:00 PM
  • OK, this is what I just did and I need an explanation why the system behaves this way:

    string result = tBoxPaymentAmount_pg5.Text.Trim();
    Decimal res = Convert.ToDecimal(result);

    Then, after some lines:

    cmdm = SetControls.createSqlParameter(cmdm, "amount", res);

    I get this bizarre COMPILE error, even before I try compilation:

    "The argument cannot convert from Decimal to String. ????

    "amount" is not a string, It is Decimal. Why does it make such a strange assumption? The first two lines work fine, no problem.


    Say what? "amount" is a string. res is a Decimal.

    If the method expects a string as the 3rd argument and
    you pass it a Decimal you will get that error.

    If the method expects a Decimal as the 2nd argument and you pass it a 
    string you will get the error saying it can't convert a string to a Decimal.

    What is the formal signature of createSqlParameter?

    What are it's parameter types?

    - Wayne

    Friday, October 12, 2018 10:26 PM
  • OK, this is what I just did and I need an explanation why the system behaves this way:

    string result = tBoxPaymentAmount_pg5.Text.Trim();
    Decimal res = Convert.ToDecimal(result);

    Then, after some lines:

    cmdm = SetControls.createSqlParameter(cmdm, "amount", res);

    I get this bizarre COMPILE error, even before I try compilation:

    "The argument cannot convert from Decimal to String. ????

    "amount" is not a string, It is Decimal. Why does it make such a strange assumption? The first two lines work fine, no problem.


    Say what? "amount" is a string. res is a Decimal.

    If the method expects a string as the 3rd argument and
    you pass it a Decimal you will get that error.

    If the method expects a Decimal as the 2nd argument and you pass it a 
    string you will get the error saying it can't convert a string to a Decimal.

    What is the formal signature of createSqlParameter?

    What are it's parameter types?

    - Wayne

    conn.Open();
    string result = tBoxPaymentAmount_pg5.Text.Trim();
    Decimal res = Convert.ToDecimal(result);
    string memow = RemoveUnprintables.GetRidOfUnprintablesAndUnicode(richTextBox_pg5.Text.Trim());
    cmdm.CommandText = "INSERT INTO [dbo].[payments] " +
            "(numeric_id, dated, debitNumeric_id, creditNumeric_id, amount, named, dateSent, " +
            "checkNumber, orderNumber, debitInstitution, creditInstitution, memo, taxDeductible, wireTransfer, ConfirmationNumber) " +
            "VALUES (@numeric_id, @dated, @debitNumeric_id, @creditNumeric_id, @amount, @named, " +
             "@datesent, @checkNumber, @orderNumber, @debitInstitution, @creditInstitution, @memo, " +
             "@taxDeductible, @wireTransfer, @ConfirmationNumber )";
    cmdm = SetControls.createSqlParameter(cmdm, "numeric_id", numeric_id);
    cmdm = SetControls.createSqlParameter(cmdm, "dated", DateTime.Now);
    cmdm = SetControls.createSqlParameter(cmdm, "debitnumeric_id", debitNumeric_id);
    cmdm = SetControls.createSqlParameter(cmdm, "creditnumeric_id", creditNumeric_id);
    cmdm = SetControls.createSqlParameter(cmdm, "amount", res);
    cmdm = SetControls.createSqlParameter(cmdm, "named", tBoxPaymentDescription_pg5.Text.Trim());
    cmdm = SetControls.createSqlParameter(cmdm, "datesent", Convert.ToDateTime(dateTimePickerPayment_pg5.Text));
    cmdm = SetControls.createSqlParameter(cmdm, "checknumber", tBoxCheckNumber_pg5.Text.Trim());
    cmdm = SetControls.createSqlParameter(cmdm, "ordernumber", tBoxOrderNumber_pg5.Text.Trim());
    cmdm = SetControls.createSqlParameter(cmdm, "debitInstitution", comboDebitInstitution_pg5.Text.Trim());
    cmdm = SetControls.createSqlParameter(cmdm, "creditinstitution", comboCreditInstitution_pg5.Text.Trim());
    cmdm = SetControls.createSqlParameter(cmdm, "memo", memow);
    cmdm = SetControls.createSqlParameter(cmdm, "taxdeductible", checkBoxTaxDeductible_pg5.Checked);
    cmdm = SetControls.createSqlParameter(cmdm, "wiretransfer", checkBoxWireTransfer_pg5.Checked);
    cmdm = SetControls.createSqlParameter(cmdm, "ConfirmationNumber", tBoxConfirmationNumber_pg5.Text.Trim());
                    }
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    try
                    {
                        cmdm.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {

    In Sql Server most parameters like "numeric_id" are varchar. Numeric_id is varchar (7). All dates are DateTime and they never cause any trouble. There is one Decimal which is "amount"

    What kind of signature do you have in mind? I don't understand.

    Only amount causes me trouble.

    - MyCatAlex


    Saturday, October 13, 2018 12:52 AM
  • I have always used Convert.ToString(decimalnumber);

    And Convert.ToInt32(string);

    I use try/catch to capture any errors.


    n.Wright

    Saturday, October 13, 2018 12:58 AM
  • What is the exact exception message you are getting?
    Saturday, October 13, 2018 2:46 AM

  • "The argument cannot convert from Decimal to String. ????

    "amount" is not a string, It is Decimal. Why does it make such a strange assumption? The first two lines work fine, no problem.


    Say what? "amount" is a string. res is a Decimal.


    In Sql Server most parameters like "numeric_id" are varchar. Numeric_id is varchar (7). All dates are DateTime and they never cause any trouble. There is one Decimal which is "amount"

    What kind of signature do you have in mind? I don't understand.

    Only amount causes me trouble.


    >There is one Decimal which is "amount"

    You're confusing SqlParamters and C# strings. As I said before, "amount"
    (note the quotes) is a C# string literal. What SQL does with it after that
    string is passed as a ParameterName is not relevant here. You are getting
    C# errors, not SQL errors.

    >What kind of signature do you have in mind? I don't understand.

    Show us the method declarations/definitions for all of the overloads of
    createSqlParameter such as:

    public static SqlCommand createSqlParameter ( SqlCommand cmdm, 
         string parName, string parValue)
            {   // overload: type string
            
            }
            
    public static SqlCommand createSqlParameter ( SqlCommand cmdm, 
          string parName,  DateTime parValue )  
            {  // overload: type DateTime         
            
            }
            
    public static SqlCommand createSqlParameter ( SqlCommand cmdm, 
       string parName,  Int32 parValue )  
            {  // overload: type Int32
            
            }
            
    

    Is there one which takes a Decimal as the 3rd parameter? Similar to this:

    public static SqlCommand createSqlParameter ( SqlCommand cmdm, 
       string parName,  Decimal parValue )
    

    If there isn't, then there is no overload that takes a Decimal as the third
    argument. So the compiler will pick an overload such as one that takes
    a string as the 3rd argument and issue a message that it can't convert
    a Decimal to a string.

    - Wayne

    Saturday, October 13, 2018 3:21 AM
  • Wayne, I am not confusing anything. You are confusing. Of course in C# source code all field names of an SQL Server table are mentioned as strings. But when the connection is established the connection makes sure that the typing of the actual parameter matches the type of each field. Look at the fields for DateTime, they are in the same situation like the Decimal which is rejected. It is a BUG. I've worked with SQL Server plus C# for years and know what I am doing. It is a Microsoft issue and must be corrected but I doubt they are up to it.

    I am afraid I will have to change the SQL field from Decimal to varchar and operate with string only. It is disgusting.

    - MyCatAlex

    Saturday, October 13, 2018 2:35 PM
  • I have always used Convert.ToString(decimalnumber);

    And Convert.ToInt32(string);

    I use try/catch to capture any errors.


    n.Wright

    You've given me a glimmer of hope but it did not work either. The exception: "System.FormatException: 'Input string was not in a correct format.'

    I changed the code slightly:

    string result = tBoxPaymentAmount_pg5.Text.Trim();

    Int32 res = Convert.ToInt32(result);   <== Exception

    Sure it expected an integer.

    I changed it to double and now I get a COMPILE objection: The argument cannot convert from double to string, instead of the argument cannot convert from Decimal to string:

    string result = tBoxPaymentAmount_pg5.Text.Trim();
                        double res = Convert.ToDouble(result);

    cmdm = SetControls.createSqlParameter(cmdm, "amount", res);   <== Compile error here.

    - MyCatAlex

    Saturday, October 13, 2018 2:52 PM


  •         

    Is there one which takes a Decimal as the 3rd parameter? Similar to this:

    public static SqlCommand createSqlParameter ( SqlCommand cmdm, 
       string parName,  Decimal parValue )

    If there isn't, then there is no overload that takes a Decimal as the third
    argument. So the compiler will pick an overload such as one that takes
    a string as the 3rd argument and issue a message that it can't convert
    a Decimal to a string.

    - Wayne

    So, you want me to use this method. The method returns an SqlCommand. Why do I need it? I already have an SqlScommand defined in my code?

    - MyCatAlex

    Saturday, October 13, 2018 4:11 PM
  • Here's the unknown: You've been calling the method SetControls.createSqlParameter() ... we don't know what that method looks like in your code. The problem probably lies there ... could you show us your method?

    ~~Bonnie DeWitt [C# MVP]

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

    Saturday, October 13, 2018 5:00 PM
    Moderator
  • Here's the unknown: You've been calling the method SetControls.createSqlParameter() ... we don't know what that method looks like in your code. The problem probably lies there ... could you show us your method?

    ~~Bonnie DeWitt [C# MVP]

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

    I posted about 30 lines of my code above with SetControls.createSqlParameter().

    - MyCatAlex

    Saturday, October 13, 2018 7:49 PM

  • So, you want me to use this method. 


    No. You're missing the significant part of the code examples I posted.
    Forget about everything except:

    The fact that the method has overloads.

    The defined parameters/arguments.

    What I said about the exception that you're seeing applies to any and all
    methods with overloads.

    I'm suggesting that in your code you appear (based on results) to have
    overloads of your method which take different parameter types. So passing
    for example a string as the 3rd argument would work because there exists
    an overload that takes a string as the 3rd argument.

    Similarly there appears to be an overload that takes a DateTime as the
    3rd parameter so calling the method with a DateTime object as the 3rd
    argument will work.

    However the results you are seeing suggest that you do not have an overload
    of your method which takes a Decimal as the 3rd parameter. So calling your
    method while passing a Decimal object as the 3rd argument will fail because
    the compiler cannot find an overload of your method which matches.

    These results suggest that you need to add an overload of your method
    which *does* accept a Decimal as an argument.

    Internally this overload will probably be very similar to the existing
    overloads, except perhaps for the use of the SqlDbType enum. In the case
    of an overload with a Decimal argument, you would likely need to use
    SqlDbType.Decimal whereas the other overloads are probably using
    SqlDbType.VarChar or SqlDbType.DateTime

    - Wayne

    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Saturday, October 13, 2018 7:56 PM
  • It certainly makes a lot of sense I can see now, but practically, how can I add an overload to the method defined by Microsoft? All overloads are in System.Data.SqlTypes namespace I presume.

    I investigated SqlDbType.Decimal and tried a few things but it all went nowhere.

    - MyCatAlex

    Saturday, October 13, 2018 8:45 PM
  • I got a compile error on SqlDbType.Decimal, although this value (Decimal) is in the dropdown menu at SqlDbType.
    Saturday, October 13, 2018 9:12 PM
  • >>I posted about 30 lines of my code above with SetControls.createSqlParameter().<<

    Yes, you posted how you called that method. But I asked about posting the actual code for the static createSqlParameter() method. I Googled and I can't find a relevant SetControls class anywhere. But, I don't know everything, perhaps it's part of a .NET namespace that I'm not familiar with. Sounds like Wayne isn't familiar with it either.

    >>but practically, how can I add an overload to the method defined by Microsoft<<

    As I hinted at above, I don't know if that's .NET Framework code. Have you've got a class defined in your application named SetControls that has a static method named createSqlParameter()? Or maybe you're using some 3rd-party assemblies? What namespace is this SetControls class in?


    ~~Bonnie DeWitt [C# MVP]

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

    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Saturday, October 13, 2018 9:19 PM
    Moderator

  •  I asked about posting the actual code for the static createSqlParameter() method. I Googled and I can't find a relevant SetControls class anywhere. But, I don't know everything, perhaps it's part of a .NET namespace that I'm not familiar with. Sounds like Wayne isn't familiar with it either.

    Right. The only example I've seen so far of its use is in a ten-year old thread:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/fce68761-5ed1-43fd-9fc1-8e1af1e84605/the-sqlparametercollection-only-accepts-nonnull-sqlparameter-type-objects-not-sqlparameter

    Note the code in the post by AlexBB showing overloads.

    Those examples also illustrate what I was referring to in my last post
    about the use of the SqlDbType enum.

    - Wayne

    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Saturday, October 13, 2018 9:33 PM
  • I got a compile error on SqlDbType.Decimal, although this value (Decimal) is in the dropdown menu at SqlDbType.

    I have no idea what you are trying to do, as I said:

    "Internally this overload will probably be very similar to the existing
    overloads, except perhaps for the use of the SqlDbType enum."

    Note the "internally" part. I was referring to what is *inside* the
    method *definition*. It has nothing to do with how you invoke the method.
    It's not an argument you are to use when *calling* the method.

    If you look at the overloads in the link I posted for the way a similar
    method is defined and used, you will see assignments such as:

    par2.SqlDbType = SqlDbType.VarChar;
    
    par2.SqlDbType = SqlDbType.DateTime;
    
    par2.SqlDbType = SqlDbType.Int;
    
    par2.SqlDbType = SqlDbType.Bit;

    I was suggesting that in an overload of the method *you're using* to
    accept a Decimal type as a 3rd argument, code such as this may need
    altering. In the case of the examples at that link, it would need to be:

    par2.SqlDbType = SqlDbType.Decimal;

    - Wayne


    • Edited by WayneAKing Sunday, October 14, 2018 1:23 AM
    Sunday, October 14, 2018 1:21 AM
  •  how can I add an overload to the method defined by Microsoft? All overloads are in System.Data.SqlTypes namespace I presume.


    Not for that method, AFAIK. Reference here:

    System.Data.SqlTypes Namespace
    https://docs.microsoft.com/en-us/dotnet/api/system.data.sqltypes?view=netframework-4.7.2

    I think you should highlight (select) SetControls.createSqlParameter in
    the IDE editor. Then right-click the mouse and from the menu select either

    Go To Definition

    or

    Go To Implementation

    See where it takes you.

    - Wayne


    • Edited by WayneAKing Sunday, October 14, 2018 4:19 AM
    • Marked as answer by MyCatAlex Sunday, October 14, 2018 5:40 PM
    Sunday, October 14, 2018 4:18 AM

  •  I asked about posting the actual code for the static createSqlParameter() method. I Googled and I can't find a relevant SetControls class anywhere. But, I don't know everything, perhaps it's part of a .NET namespace that I'm not familiar with. Sounds like Wayne isn't familiar with it either.

    Right. The only example I've seen so far of its use is in a ten-year old thread:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/fce68761-5ed1-43fd-9fc1-8e1af1e84605/the-sqlparametercollection-only-accepts-nonnull-sqlparameter-type-objects-not-sqlparameter

    Note the code in the post by AlexBB showing overloads.

    Those examples also illustrate what I was referring to in my last post
    about the use of the SqlDbType enum.

    - Wayne

    Wayne hi,

    It sounds interesting and I will try it soon. I just got up from sleep. It is early morning in our zone.

    Thanks, - MyCatAlex

    Sunday, October 14, 2018 1:27 PM
  • Wayne hi,

    Thank you very much. Everything works now! I marked your posts as answers.

    conn.Open();
                        string memow = RemoveUnprintables.GetRidOfUnprintablesAndUnicode(richTextBox_pg5.Rtf.Trim());
                        cmdm.CommandText = "INSERT INTO [dbo].[payments] " +
                            "(numeric_id, dated, debitNumeric_id, creditNumeric_id, amount, named, dateSent, " +
                            "checkNumber, orderNumber, debitInstitution, creditInstitution, memo, taxDeductible, wireTransfer, ConfirmationNumber) " +
                            "VALUES (@numeric_id, @dated, @debitNumeric_id, @creditNumeric_id, @amount, @named, " +
                            "@datesent, @checkNumber, @orderNumber, @debitInstitution, @creditInstitution, @memo, " +
                            "@taxDeductible, @wireTransfer, @ConfirmationNumber )";
    
                        //This is the SqlParameter Array 
                        SqlParameter[] sqlParams = new SqlParameter[]
                        {
                             new SqlParameter("@numeric_id", numeric_id),
                             new SqlParameter("@dated", DateTime.Now),
                             new SqlParameter("@debitNumeric_id", debitNumeric_id),
                             new SqlParameter("@creditNumeric_id", creditNumeric_id),
                             new SqlParameter("@amount", Convert.ToDecimal (tBoxPaymentAmount_pg5.Text.Trim())),
                             new SqlParameter("@named", tBoxPaymentDescription_pg5.Text.Trim()),
                             new SqlParameter("@dateSent", Convert.ToDateTime(dateTimePickerPayment_pg5.Text)),
                             new SqlParameter("@checknumber", tBoxCheckNumber_pg5.Text.Trim()),
                             new SqlParameter("@ordernumber", tBoxOrderNumber_pg5.Text.Trim()),
                             new SqlParameter("@debitInstitution", comboDebitInstitution_pg5.Text.Trim()),
                             new SqlParameter("@creditInstitution", comboCreditInstitution_pg5.Text.Trim()),
                             new SqlParameter("@memo", memow),
                             new SqlParameter("@taxDeductible", checkBoxTaxDeductible_pg5.Checked),
                             new SqlParameter("@wireTransfer", checkBoxWireTransfer_pg5.Checked),
                             new SqlParameter("@confirmationNumber", tBoxConfirmationNumber_pg5.Text.Trim())
                        };
                        cmdm.Parameters.AddRange (sqlParams);
                    }
    
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    try
                    {
                        cmdm.ExecuteNonQuery();
                    }

    Sunday, October 14, 2018 5:42 PM