I have experienced an error on
"The parametrized query '(@blue nvarchar(4000))SELECT blueBallImage FROM CorrespondingBal' expects the parameter '@blue',
which was not supplied."
I am doing a HttpHandler.
I want to retrieve the image from the database. My codes are as below.
public void ProcessRequest (HttpContext context) {
string image = context.Request.QueryString["image"];
SqlConnection con = new SqlConnection(@"Data Source=localhost;Initial Catalog=MyCloudGames;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT blueBallImage FROM CorrespondingBall WHERE objective = blue", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("blue", image);
con.Open();
byte[] ballImage = (byte[])cmd.ExecuteScalar();
con.Close();
context.Response.ContentType = "image/png";
context.Response.OutputStream.Write(ballImage, 78, ballImage.Length - 78);
}
The error occurred at
byte[] ballImage = (byte[])cmd.ExecuteScalar();