Exec up_GetAtt @pageNumber=1, @pagesize=10, @PID=1000, @DeID=NULL,
@DeName =NULL, @SortByColumn='ReleaseDate', @SortOrder='DESC' this are
the parameters I am passing
You need to convert the C# null values into DBNull
SqlConnection connection = Connect();
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = sprocName;
command.Connection = connection;
//loop through the dictionary
foreach (string key in paramList.Keys)
{
command.Parameters.AddWithValue(key, paramList[key] == NULL? DBNull.Value : paramList[key]);
}
SqlDataReader dataReader = command.ExecuteReader();
Given the lack of information to help you better, check also for common mistakes
- Typos in proc and parameter names
- Sending a query with CommandType.StoredProcedure: sprocName value must be just "up_GetAtt", is a common mistake to include the EXEC word or parameters.
- Check Value Types, your paramList should be a dictionary, and the value type of the items that you put in that list should match with the sql equivalent type, not all types have implicit conversion.
- Check nullability of paramList items, use nullable int and datetime
- Check that the parameter names start with @
- Omitting a parameter does not mean that it is null, unless your store procedure definition default it as null
- Omitting a parameter with no default value in procedure definition
- Unnecessary quotation of values, you are sending parameter values, it is not a concat