0

I have my form set in french as well, and it automatically changes the text format to use ','. However When I try to insert my values into the database it says cannot convert nvarchar to decimal?

Worst case, Is there a way I can disable the numbers from changing to use ',' and just use '.' always regardless what language it is?

My working language is vb.net

Thanks,

Robert

Robert
  • 51
  • 1
  • 2
  • 4

1 Answers1

0

If you're passing the values down to the database as nvarchar then you'll need to have converted this to a string using yourDecimalValue.ToString(Globalization.CultureInfo.InvariantCulture) or similar. SQL Server will always expect a decimal to be in 1.23 format - you can imagine the trouble that would result if queries including WHERE myvalue IN (1,25, 1,33, 1,45) were submitted!

Will A
  • 24,780
  • 5
  • 50
  • 61
  • Another option is to not use query strings directly and instead use stored procedures - where you can just set the parameter value to a Decimal and no Decimal -> String conversion is involved. – Will A Jul 18 '10 at 07:40
  • Is it possible to keep the numbers with decimal places, rather show "," . is it a universal setting? – Robert Jul 18 '10 at 07:46
  • Where would you want them to show ","? In the client program - probably I guess - when passed down to SQL - definitely not. – Will A Jul 18 '10 at 07:52