我想根據打開窗口窗體的用戶選擇一張照片。動態值在where子句中
如果我在where子句中添加一個數字「where id = 36」,它只顯示ID 34(它的靜態)的照片。我怎樣才能使它動態?每個用戶都有自己的照片,所以應該加載。下面的代碼。
cmd = new SqlCommand("select profilepic from users where [email protected]", con);
cmd.Parameters.Add("@ID", SqlDbType.Int);
cmd.Parameters["@ID"].Value = profilePic;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
MemoryStream ms = new MemoryStream((byte[])ds.Tables[0].Rows[0]["profilepic"]);
pictureBox1.Image = new Bitmap(ms);
}
檢出sql參數。 – juharr