Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Program With Multi language support

Program With Multi language support

Scheduled Pinned Locked Moved C#
databasecomsysadminsecurityhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arunkumar Koloth
    wrote on last edited by
    #1

    Hi all i created a database and table for language and translations the fileds are like this language-> languagename,languagecode English 101 Hindi 102 translation-> textinenglish,languagecode,translated Hellow 101 Hellow Hellow 102 hindihellow Now I Have A Combo box in my form and 1 label I Need To Change label text to the selected language in combobox so i writed code like this but i dont know how to get the value from database Please Help me

    SqlConnection con = new SqlConnection("server=ARUN-09BF105DE8\\AR; initial catalog=prod; integrated security=true");
    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
    object scode;
    scode = comboBox1.SelectedValue;
    changelanguage(scode);
    }
    public void changelanguage(object code) {
    con.Open();
    SqlCommand com = new SqlCommand();
    SqlDataReader dr;
    com.Parameters.AddWithValue("language", code);
    com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
    dr=com.ExecuteReader();

        }
    

    Trust one who has tried

    OriginalGriffO P 2 Replies Last reply
    0
    • A Arunkumar Koloth

      Hi all i created a database and table for language and translations the fileds are like this language-> languagename,languagecode English 101 Hindi 102 translation-> textinenglish,languagecode,translated Hellow 101 Hellow Hellow 102 hindihellow Now I Have A Combo box in my form and 1 label I Need To Change label text to the selected language in combobox so i writed code like this but i dont know how to get the value from database Please Help me

      SqlConnection con = new SqlConnection("server=ARUN-09BF105DE8\\AR; initial catalog=prod; integrated security=true");
      private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
      object scode;
      scode = comboBox1.SelectedValue;
      changelanguage(scode);
      }
      public void changelanguage(object code) {
      con.Open();
      SqlCommand com = new SqlCommand();
      SqlDataReader dr;
      com.Parameters.AddWithValue("language", code);
      com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
      dr=com.ExecuteReader();

          }
      

      Trust one who has tried

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      If you look here: http://stackoverflow.com/questions/119568/best-practice-to-make-a-multi-language-application-in-c-winforms[^] there is a discussion of the various ways to achieve this. The way you have selected is not necessarily the best: it requires a version of SQLServer to be available to each PC on which your app will run, which may not be possible or desirable. However:

          public void changelanguage(object code) {
              con.Open();
              SqlCommand com = new SqlCommand();
              SqlDataReader dr;
              com.Parameters.AddWithValue("language", code);
              com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
              dr=com.ExecuteReader();
              while (dr.Read()) {
                  if ((string) dr\["textinenglish"\] == theWordIWantToTranslate) {
                      ...
                      }
                  }
              }
      

      BTW: Please remember that you are responsible for Close-ing and Dispose-ing all of the SQLCommand and SQLConnection objects you create!

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • A Arunkumar Koloth

        Hi all i created a database and table for language and translations the fileds are like this language-> languagename,languagecode English 101 Hindi 102 translation-> textinenglish,languagecode,translated Hellow 101 Hellow Hellow 102 hindihellow Now I Have A Combo box in my form and 1 label I Need To Change label text to the selected language in combobox so i writed code like this but i dont know how to get the value from database Please Help me

        SqlConnection con = new SqlConnection("server=ARUN-09BF105DE8\\AR; initial catalog=prod; integrated security=true");
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        object scode;
        scode = comboBox1.SelectedValue;
        changelanguage(scode);
        }
        public void changelanguage(object code) {
        con.Open();
        SqlCommand com = new SqlCommand();
        SqlDataReader dr;
        com.Parameters.AddWithValue("language", code);
        com.CommandText = "SELECT translated FROM translation WHERE languagecode=@language";
        dr=com.ExecuteReader();

            }
        

        Trust one who has tried

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Arunkumar.Koloth wrote:

        AddWithValue("language",

        Don't forget the @. And, yeah, that doesn't look like the best way to do it.

        A 1 Reply Last reply
        0
        • P PIEBALDconsult

          Arunkumar.Koloth wrote:

          AddWithValue("language",

          Don't forget the @. And, yeah, that doesn't look like the best way to do it.

          A Offline
          A Offline
          Arunkumar Koloth
          wrote on last edited by
          #4

          can you tell me a good way to do this?

          P 1 Reply Last reply
          0
          • A Arunkumar Koloth

            can you tell me a good way to do this?

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            No, I've never done it.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups