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. multiple textbox text save in one field

multiple textbox text save in one field

Scheduled Pinned Locked Moved C#
helptutorial
10 Posts 2 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.
  • M Offline
    M Offline
    mjawadkhatri
    wrote on last edited by
    #1

    hi.. I need 2 know How i am Insert multiple textbox text in one field For Example I have one Field name data and i have 3 textbox i want to insert 3 textbox data in one field. hope u understand my problem i am waiting your response. Thanks In advance Jawad khatri

    C 1 Reply Last reply
    0
    • M mjawadkhatri

      hi.. I need 2 know How i am Insert multiple textbox text in one field For Example I have one Field name data and i have 3 textbox i want to insert 3 textbox data in one field. hope u understand my problem i am waiting your response. Thanks In advance Jawad khatri

      C Offline
      C Offline
      Calla
      wrote on last edited by
      #2

      I don't get what the problem is? Where do you fail in your attempt to copy the data from your textboxes? You access the data in a textbox by using the Text property..

      M 1 Reply Last reply
      0
      • C Calla

        I don't get what the problem is? Where do you fail in your attempt to copy the data from your textboxes? You access the data in a textbox by using the Text property..

        M Offline
        M Offline
        mjawadkhatri
        wrote on last edited by
        #3

        yes i want to access data to text property let suppose i have 3 textboxes text1.text = I text2.text = am text3.text - jawad now i want to save these 3 textboxes data in one field

        C 1 Reply Last reply
        0
        • M mjawadkhatri

          yes i want to access data to text property let suppose i have 3 textboxes text1.text = I text2.text = am text3.text - jawad now i want to save these 3 textboxes data in one field

          C Offline
          C Offline
          Calla
          wrote on last edited by
          #4

          Just concatenate your textbox content to a string:

          string theString = string.Empty;
          text1.Text = "I";
          text2.Text = "am";
          text3.Text = "jawad";
          theString = text1.Text + text2.Text + text3.Text;

          Still not sure if this is what you're after though..:confused:

          M 1 Reply Last reply
          0
          • C Calla

            Just concatenate your textbox content to a string:

            string theString = string.Empty;
            text1.Text = "I";
            text2.Text = "am";
            text3.Text = "jawad";
            theString = text1.Text + text2.Text + text3.Text;

            Still not sure if this is what you're after though..:confused:

            M Offline
            M Offline
            mjawadkhatri
            wrote on last edited by
            #5

            thanks for response. i have a table Data have one field name description. and i have 3 textboxes Rate,Weight,Product i want to save data of Rate,Weight,Product in description field Now hope u understand

            C 1 Reply Last reply
            0
            • M mjawadkhatri

              thanks for response. i have a table Data have one field name description. and i have 3 textboxes Rate,Weight,Product i want to save data of Rate,Weight,Product in description field Now hope u understand

              C Offline
              C Offline
              Calla
              wrote on last edited by
              #6

              Is "Data" a table in a database? Could you post the code you're having trouble with and describe what goes wrong and what you want it to do?

              M 1 Reply Last reply
              0
              • C Calla

                Is "Data" a table in a database? Could you post the code you're having trouble with and describe what goes wrong and what you want it to do?

                M Offline
                M Offline
                mjawadkhatri
                wrote on last edited by
                #7

                Yes Data Is table in database SqlConnection conn = new SqlConnection(connString); string query = "insert into Data(Product,discription) values('" + txtproduct.Text + "','" + txtrate.Text + "'&& '" + txtweight.Text + "')"; SqlCommand cmd = new SqlCommand(query, conn); try { conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted Sucessfully."); } finally { conn.Close(); }

                C 1 Reply Last reply
                0
                • M mjawadkhatri

                  Yes Data Is table in database SqlConnection conn = new SqlConnection(connString); string query = "insert into Data(Product,discription) values('" + txtproduct.Text + "','" + txtrate.Text + "'&& '" + txtweight.Text + "')"; SqlCommand cmd = new SqlCommand(query, conn); try { conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted Sucessfully."); } finally { conn.Close(); }

                  C Offline
                  C Offline
                  Calla
                  wrote on last edited by
                  #8

                  Okay, and what is the error your receiving? Do you really want the concatenated string to look like this (if txtrate=theRating, txtweight=theWeight)? theRating'&&'theWeight Or do you want: theRating&&theWeight Check the part where you put your strings together. If you want to use a ' in your concatenated string you have to use double '' like this:

                  string query = "insert into Data(Product,discription) values('" + textBox1.Text + "','" + textBox2.Text + "''&& ''" + textBox3.Text + "')";

                  modified on Friday, March 12, 2010 7:01 AM

                  M 1 Reply Last reply
                  0
                  • C Calla

                    Okay, and what is the error your receiving? Do you really want the concatenated string to look like this (if txtrate=theRating, txtweight=theWeight)? theRating'&&'theWeight Or do you want: theRating&&theWeight Check the part where you put your strings together. If you want to use a ' in your concatenated string you have to use double '' like this:

                    string query = "insert into Data(Product,discription) values('" + textBox1.Text + "','" + textBox2.Text + "''&& ''" + textBox3.Text + "')";

                    modified on Friday, March 12, 2010 7:01 AM

                    M Offline
                    M Offline
                    mjawadkhatri
                    wrote on last edited by
                    #9

                    I have Done :) Thanks For Help Me Sir

                    C 1 Reply Last reply
                    0
                    • M mjawadkhatri

                      I have Done :) Thanks For Help Me Sir

                      C Offline
                      C Offline
                      Calla
                      wrote on last edited by
                      #10

                      You're welcome :)

                      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