我是.net的新手。尽管我已经阅读了之前记录的同一问题的其他一些答案。我无法在我的代码中找到它。
请有人解释我在哪里做错了。
我的代码:
string id = context.Request.QueryString["id"];
if (id != null)
{
SAConnection Conn = new SAConnection(WebConfigurationManager.ConnectionStrings["P4ConnectionString"].ConnectionString);
string query = "select Embedded_Image from dba.Image where Record_No=" + id;
SACommand Cmd = new SACommand(query, Conn);
Conn.Open();
SADataReader dr = Cmd.ExecuteReader();
if (dr.Read())
{
byte[] bytes = (byte[])dr["Embedded_Image"];
context.Response.BinaryWrite(bytes);
}
dr.Close();
Cmd.Dispose();
Conn.Close();
}
当它遇到byte[] bytes = (byte[])dr["Embedded_Image"];
行时,我收到错误。
提前致谢