I am taking value from textbox1 and trying to pass that value to stored procedure. but while creating stored procedure I am getting below error
Msg 102, Level 15, State 1, Procedure proc_1, Line 8
Incorrect syntax near '@name'.
in c#
string nam = " and city='" + textbox1.Text + "'";
cmd.Parameters.AddWithValue("@name", nam );
create procedure proc_1
(
@name varchar (max)
)
as
begin
select [country] from table_name where city='delhi' @name
end
please let me know, how can I insert the textbox1 value into @name variable
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Akkiraju IvaturiRank #473 · 5.3K reputationPosted Jan 16, 2013, 5:45 AM EST
select [country] from table_name where city = @name
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 16, 2013, 5:51 PM EST
I think concatenation operator is missing before @name.
create procedure proc_1
(
@name varchar (max)
)
as
begin
select [country] from table_name where city='delhi' + @name
end
hope this will help you.
Dinesh Bhoje23 reputationPosted Jan 16, 2013, 7:24 PM EST
in c#
string nam = textbox1.Text;
cmd.Parameters.AddWithValue("@name", nam );
In Storedprocedure..
create procedure proc_1
(
@name varchar (max)
)
as
begin
select [country] from table_name where city=@name
end
Engg. Rocks...........