By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

fast replay : regional setting

P: 8
i am writing following code to insert value in table test which has two fields
id , current_ date but if i change
regional seting English(United Staes ) to french(France) then it hows error

it show error if regionl setting is English(United Staes ) value inserted sucessfully
any one tell how i set regional setting for my project
Expand|Select|Wrap|Line Numbers
  1.  
  2.     try
  3.             {
  4.                     ss = DateTime.Now;
  5.                 objSqlConnection.Open();
  6.                 SqlCommand objSqlCommand = new  SqlCommand ("insert into test values ( '" + ss + "',125)",objSqlConnection);
  7.                 objSqlCommand.ExecuteNonQuery();
  8.                 MessageBox.Show("Inserted sucessfully");
  9.                 objSqlConnection.Close();
  10.             }
  11.             catch(Exception ex)
  12.             {
  13.                 MessageBox.Show(ex.Message);
  14.                 objSqlConnection.Close();
  15.             }
Nov 16 '07 #1
Share this Question
Share on Google+
5 Replies


kunal pawar
100+
P: 297
Can u tell Error ??
It may be the problem of column name. Whn u changed the Regional setting it will change Column name too, which are not same as SQL Server Table column name
Nov 16 '07 #2

P: 8
hi
error is conversion char datatype to datatype datetime
&& current date in following forat 01/01/0001 00:00:00
Nov 16 '07 #3

Expert 100+
P: 390
You have to specify the proper Date format while inserting the data.
Nov 16 '07 #4

Expert 100+
P: 487
You have to insert the date format as

Expand|Select|Wrap|Line Numbers
  1. string.Format("{0:MM/dd/yyyy}",DateTime.Now);
  2.  
  3. //or
  4. string.Format("{0:yyyy/MM/dd}",DateTime.Now);
Otherwise it will consider as string.
Nov 16 '07 #5

Frinavale
Expert Mod 5K+
P: 9,731
You should check your Resources that handle your Cultural Regions so that it formats dates as well as other data types (like numbers) correctly.
Nov 16 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.