I am using Visual Studio 2017, created a C# .NET Web Service. I have created a function in my model and i want to make an SQL Insertion using stored procedures. The problem is that i get the error :
Could not find stored procedure 'createEmployee'
Do i have to define the procedure "createEmployee" somewhere else? Code below :
public string create()
{
using (SqlConnection mConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString))
{
using (SqlCommand mCommand = new SqlCommand("createEmployee", mConnection))
{
mCommand.CommandType = CommandType.StoredProcedure;
mCommand.Parameters.AddWithValue("@name", Name);
mCommand.Parameters.AddWithValue("@surname", Surname);
mCommand.Parameters.AddWithValue("@phone", Phone);
mCommand.Parameters.AddWithValue("@gender", Gender);
mCommand.Parameters.AddWithValue("@salary", Salary);
mCommand.Parameters.AddWithValue("@country", Country);
try
{
mConnection.Open();
mCommand.ExecuteNonQuery();
return "success";
}
catch (SqlException e)
{
return e.Message.ToString();
}
}
}
}