SqlDataAdapter da = default(SqlDataAdapter);
DataTable dt = new DataTable();
SQL = "select * from TestPic where picName= @picName";
da = new SqlDataAdapter(SQL, conn);
//cmd = da.SelectCommand();
SqlCommand cmd = new SqlCommand(SQL, conn);
cmd.Parameters.Add("@picName", SqlDbType.Int).Value = Request.QueryString["picName"].ToString();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Response.ContentType = dt.Rows[0]["picType"].ToString();
Response.BinaryWrite((byte[])dt.Rows[0]["picName"]);
}
ตรง cmd.Parameters.Add("@picName", SqlDbType.Int).Value = Request.QueryString["picName"].ToString(); มันแจ้งว่า
Object reference not set to an instance of an object. อ่ะครับ