TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pravinkumar Birajdar
1.1k
584
109.4k
Parameter Error in Stored Procedure
Oct 11 2019 12:16 AM
Error:
Procedure or function 'SaveUpdateEmp' expects parameter '@EmpID', which was not supplied.
Stored Procedure:
CREATE
PROCEDURE
[dbo].[SaveUpdateEmp]
@EmpID
varchar
(10),
@EmpName
varchar
(100),
@DesID
int
,
@Salary money,
@Result
varchar
(50)
out
AS
begin
declare
@ID
varchar
(10)
select
@ID= EmpID
from
Emp
where
EmpName=@EmpName
if(@ID<>
''
and
@EmpID=
''
)
begin
set
@Result=
'Employee name is already exist !!!'
end
else
begin
if(@EmpID=
''
)
begin
insert
into
Emp(EmpName,DesID,Salary)
values
(@EmpName,@DesID,@Salary)
set
@Result=
'Employee saved successfully'
end
else
begin
update
Emp
set
EmpName=@EmpName,DesID=@DesID,Salary=@Salary
where
EmpID=@EmpID
set
@Result=
'Employee updated successfully'
end
end
end
protected
void
btnSave_Click(
object
sender, EventArgs e)
{
try
{
SqlConnection con =
new
SqlConnection(Commons.GetConnectionString);
SqlCommand cmd =
new
SqlCommand(
"SaveUpdateEmp"
, con);
cmd.Parameters.AddWithValue(
"@EmpID"
, HiddenField1.Value);
cmd.Parameters.AddWithValue(
"@EmpName"
, txtEmpName.Text);
cmd.Parameters.AddWithValue(
"@DesID"
, ddlDesignation.SelectedValue);
cmd.Parameters.AddWithValue(
"@Salary"
, txtSalary.Text);
cmd.Parameters.Add(
"@Result"
, SqlDbType.VarChar,30);
cmd.Parameters[
"@Result"
].Direction = ParameterDirection.Output;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lblMsg.Text = cmd.Parameters[
"@Result"
].Value.ToString();
}
catch
(Exception ex)
{
throw
ex;
}
}
Reply
Answers (
4
)
Pass one value at a time from the list
how to calculate lat & long using Addres in c#