It's not going to matter what type in your db it is, the value being parsed is coming from a textbox and, therefore, the value in the textbox has to be a valid string representation of a decimal in the current culture (ex. if textbox value uses ',' for decimal point then your Windows culture setting must use ',' for decimal point), or else you have to specify formatting with Decimal.Parse() .
I tried your code and it worked for me with a good value for textBox1.text.
Could you please give an actual value from your textbox that generates this error?
Last edited by Michael Gorsich; Oct 18 '16, 12:22 PM.
Reason: More info.
It would really help if you posted the code where it Actually crashed. The code that you posted will not crash.
It would also help if you mentioned what type of database you are connecting to and whether you are trying to retrieve information from the database or insert/update information into the database.
Comment