fast replay : regional setting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hemantpatil
    New Member
    • Nov 2007
    • 8

    fast replay : regional setting

    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
    [code=cpp]

    try
    {
    ss = DateTime.Now;
    objSqlConnectio n.Open();
    SqlCommand objSqlCommand = new SqlCommand ("insert into test values ( '" + ss + "',125)",objSql Connection);
    objSqlCommand.E xecuteNonQuery( );
    MessageBox.Show ("Inserted sucessfully");
    objSqlConnectio n.Close();
    }
    catch(Exception ex)
    {
    MessageBox.Show (ex.Message);
    objSqlConnectio n.Close();
    }[/code]
    Last edited by Frinavale; Nov 16 '07, 03:14 PM. Reason: Added [code] tags
  • kunal pawar
    Contributor
    • Oct 2007
    • 297

    #2
    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

    Comment

    • hemantpatil
      New Member
      • Nov 2007
      • 8

      #3
      hi
      error is conversion char datatype to datatype datetime
      && current date in following forat 01/01/0001 00:00:00

      Comment

      • mzmishra
        Recognized Expert Contributor
        • Aug 2007
        • 390

        #4
        You have to specify the proper Date format while inserting the data.

        Comment

        • CyberSoftHari
          Recognized Expert Contributor
          • Sep 2007
          • 488

          #5
          You have to insert the date format as

          [CODE=cpp]string.Format(" {0:MM/dd/yyyy}",DateTime .Now);

          //or
          string.Format(" {0:yyyy/MM/dd}",DateTime.N ow);[/CODE]
          Otherwise it will consider as string.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            You should check your Resources that handle your Cultural Regions so that it formats dates as well as other data types (like numbers) correctly.

            Comment

            Working...