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. Insert 2 textbox text in one field

Insert 2 textbox text in one field

Scheduled Pinned Locked Moved C#
help
9 Posts 5 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 try to insert 2 textbox text in one field but i face a problem please help me my code is SqlConnection conn = new SqlConnection(connString); string v_query = "insert into voucher_2 (heads,credit,debit,descp,vdate) values('" + partyname.Text + "',' 0 ','" + Amount.Text + "','" + qty.Text && rate.Text + "','" + Date.Text + "')"; SqlCommand cmd = new SqlCommand(v_query,conn); try { conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted."); } finally { conn.Close(); } Error IS perator '&&' cannot be applied to operands of type 'string' and 'string'

    N C I 3 Replies Last reply
    0
    • M mjawadkhatri

      Hi.. I try to insert 2 textbox text in one field but i face a problem please help me my code is SqlConnection conn = new SqlConnection(connString); string v_query = "insert into voucher_2 (heads,credit,debit,descp,vdate) values('" + partyname.Text + "',' 0 ','" + Amount.Text + "','" + qty.Text && rate.Text + "','" + Date.Text + "')"; SqlCommand cmd = new SqlCommand(v_query,conn); try { conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted."); } finally { conn.Close(); } Error IS perator '&&' cannot be applied to operands of type 'string' and 'string'

      N Offline
      N Offline
      nagendrathecoder
      wrote on last edited by
      #2

      Ofcourse, && is Logical AND operator. You can use + operator to combine two strings. :)

      1 Reply Last reply
      0
      • M mjawadkhatri

        Hi.. I try to insert 2 textbox text in one field but i face a problem please help me my code is SqlConnection conn = new SqlConnection(connString); string v_query = "insert into voucher_2 (heads,credit,debit,descp,vdate) values('" + partyname.Text + "',' 0 ','" + Amount.Text + "','" + qty.Text && rate.Text + "','" + Date.Text + "')"; SqlCommand cmd = new SqlCommand(v_query,conn); try { conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted."); } finally { conn.Close(); } Error IS perator '&&' cannot be applied to operands of type 'string' and 'string'

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

        What are you trying to acheive? If you want to concatenate two strings, then use the '+' operator. qty.Text + rate.Text

        M 2 Replies Last reply
        0
        • C Calla

          What are you trying to acheive? If you want to concatenate two strings, then use the '+' operator. qty.Text + rate.Text

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

          Thanks For Good And Fast reply :)

          1 Reply Last reply
          0
          • M mjawadkhatri

            Hi.. I try to insert 2 textbox text in one field but i face a problem please help me my code is SqlConnection conn = new SqlConnection(connString); string v_query = "insert into voucher_2 (heads,credit,debit,descp,vdate) values('" + partyname.Text + "',' 0 ','" + Amount.Text + "','" + qty.Text && rate.Text + "','" + Date.Text + "')"; SqlCommand cmd = new SqlCommand(v_query,conn); try { conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted."); } finally { conn.Close(); } Error IS perator '&&' cannot be applied to operands of type 'string' and 'string'

            I Offline
            I Offline
            Ice_Freez05
            wrote on last edited by
            #5

            try declaring a string variable and pass the value of two textbox.text in the declared variable... string strTxtVal = ""; strTxtVal = qty.Text + rate.Text;

            1 Reply Last reply
            0
            • C Calla

              What are you trying to acheive? If you want to concatenate two strings, then use the '+' operator. qty.Text + rate.Text

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

              How to create spaces between them???

              I C L 3 Replies Last reply
              0
              • M mjawadkhatri

                How to create spaces between them???

                I Offline
                I Offline
                Ice_Freez05
                wrote on last edited by
                #7

                qty.Text + " " + rate.Text

                1 Reply Last reply
                0
                • M mjawadkhatri

                  How to create spaces between them???

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

                  qty.Text + " " + rate.Text

                  1 Reply Last reply
                  0
                  • M mjawadkhatri

                    How to create spaces between them???

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    how to use brain cells? how to read book? how to ask questions? :~

                    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                    Prolific encyclopedia fixture proof-reader browser patron addict?
                    We all depend on the beast below.


                    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