We have a stored procedure created in the database. It is working just fine but I am not able to figure out how to call it within my code. For some reason I keep getting back
Procedure or function 'GetNextApplicationNumber' expects parameter '@ApplicationId', which was not supplied.
My code:
string connectionString = "THE_CONNECTION_STRING";
using (IDbConnection connection = new SqlConnection(connectionString))
using (IDbCommand command = connection.CreateCommand())
{
command.CommandType = CommandType.StoredProcedure;
IDbDataParameter parameter = command.CreateParameter();
parameter.ParameterName = "@ApplicationId";
parameter.Value = applicationId;
parameter.DbType = DbType.String;
command.Parameters.Add(parameter);
command.CommandText = "[dbo].[GetNextApplicationNumber]";
connection.Open();
using (IDataReader reader = command.ExecuteReader())
{
string applicationNumber = string.Empty;
if (reader.Read())
{
applicationNumber = reader.GetValue(0).ToString();
}
return applicationNumber;
}
}
I have tried quite a few different ways (most of which seem to be outdated and no longer available).