I've written some code to get some data out of my database. The stored procedure only uses the ID as the parameter, and uses that to filter results. I've run the stored procedure using the EXEC command in SSMS and it works. However, when I try and call it using the code at the bottom, it fails, saying that I have not provided the parameter. Can anyone see what I'm doing wrong?
using (SqlConnection sqlConnect = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
try
{
DataTable dtBets = new DataTable("All Bets");
using (SqlDataAdapter sqlDA = new SqlDataAdapter("up_Select_all", sqlConnect))
{
sqlDA.SelectCommand.Parameters.Add("@ID", SqlDbType.BigInt).Value = pCustomer.CustomerID;
sqlDA.Fill(dtBets);
return dtBets;
}
}
catch (SqlException ex)
{
//catch code
}