Insert 2 textbox text in one field
-
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'
-
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'
Ofcourse, && is Logical AND operator. You can use + operator to combine two strings. :)
-
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'
-
What are you trying to acheive? If you want to concatenate two strings, then use the '+' operator.
qty.Text + rate.Text
Thanks For Good And Fast reply :)
-
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'
try declaring a string variable and pass the value of two textbox.text in the declared variable... string strTxtVal = ""; strTxtVal = qty.Text + rate.Text;
-
What are you trying to acheive? If you want to concatenate two strings, then use the '+' operator.
qty.Text + rate.Text
How to create spaces between them???
-
How to create spaces between them???
qty.Text + " " + rate.Text
-
How to create spaces between them???
-
How to create spaces between them???
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.