Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
create table employees
(firstName nvarchar(50),
LastName nvarchar(50),
FullName nvarchar(50))


Textox1.text = john
Textbox2.text= cena


I need to insert to fullName = 'john cena' From Two TextBox(TextBox1,TextBox2);


This My Code:

SqlCommand cmd2 = new SqlCommand("insertEmployyesTBL", con2);
cmd2.CommandType = System.Data.CommandType.StoredProcedure;

cmd2.Parameters.AddWithValue("@firstName", Textox1.Text);
cmd2.Parameters.AddWithValue("@LastName", Textbox2.Text);
cmd2.Parameters.AddWithValue("@FullName ",
Posted
Updated 11-Oct-15 4:23am
v2
Comments
[no name] 11-Oct-15 11:02am    
You are correct way to achieve the same. And also you are adding fullname as parameter, that is also fine. But it from your question it is not visible what are you providing. So add lik below:
cmd2.Parameters.AddWithValue("@FullName", TextBox1.Text + " " +TextBox2.Text);

1 solution

There is a method for that built into .NET:
C#
cmd2.Parameters.AddWithValue("@FullName", string.Join(" ", Textbox1.Text, Textbox2.Text));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900