apacay apacay - 2 months ago 15
SQL Question

Procedure or function expects parameter '@id' which was not supplied

what am I missing?

private void GetGeneralData(ReportPackage myPackage)
{
using (SqlConnection conn = new SqlConnection(mySqlConn))
{
using (SqlCommand cmd = new SqlCommand("[dbo].[GetStuff]", conn))
{
cmd.Parameters.AddWithValue("@id", myPackage.IdDeliverable);

conn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
dr.Read();
myPackage.DeployServer = dr.GetString(0);
myPackage.Connection = dr.GetString(1);
}
}
}
}



Procedure or function 'GetStuff' expects parameter '@id', which was not supplied.

Answer

Try adding

cmd.CommandType = CommandType.StoredProcedure

Comments