I can't really find a definitive answer to what happens if for example my decimals are stored in the database with different culture settings and I want to get them via a SqlDataReader into my program. Will the ',' and '.' always be correctly parsed and converted to my current culture as long as the data type in the SQL-DB is set to decimal?
What happens if they are stored in a varchar and try to use .GetDecimal()?
SqlDataReaderdoes not use anyCultureInfoor something equivalent. It's not aware of cultures.When your values are stored in the db as decimal, the SqlDataReader receives that decimal value. How they are (string-) represented in your app then depends how you do it: simply with
dataReader["myColumn"].ToString()will use your currentCultureInfo. If you want a different culture, you have to provide that explicitly.When they are stored as strings, you have a problem (at least if you don't know the culture these strings were created with). You have to use the correct
CultureInfoto first parse those strings to get the correct values. But why would you store numbers as strings in your db, anyway?