我在数据库中有一个包含名称和图像的表我想根据文本框中给出的名称加载图像
string strQuery = "select img from exp where name='" + TextBox1.Text + "'";
这在 aspx 中很好,但在图像处理程序 ashx 文件中,我想传递此文本框的值,以便可以应用相同的 sql 查询
直到现在我的处理程序文件是
using System;
using System.Web;
using System.Data.SqlClient;
public class ShowImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string imageid = context.Request.QueryString["img"];
SqlConnection con = new SqlConnection("server=.\\SQLEXPRESS;database=experiment;trusted_connection=true;");
con.Open();
SqlCommand command = new SqlCommand("select img from exp where (here i stuck....)", con);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
context.Response.BinaryWrite((Byte[])dr[0]);
con.Close();
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
我想要这个在 c# asp.net 中。