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 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dinesh BhojePosted Jan 17, 2013, 12:24 AM
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...........
Jignesh TrivediPosted Jan 16, 2013, 10:51 PM
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.
Akkiraju IvaturiPosted Jan 16, 2013, 10:45 AM
select [country] from table_name where city = @name