我有一個問題,當我從內存流中的數據庫檢索圖像時,它會給出錯誤Parameter is not valid
。請幫我解決這個問題。從SQL Server數據庫檢索圖像
代碼:
private void button3_Click(object sender, EventArgs e)
{
string strcon = "Data Source=PINKAL-PC; initial catalog=testing; integrated security=SSPI;";
SqlConnection sqlcon = new SqlConnection(strcon);
sqlcon.Open();
string strquery = "select * from testimg";
SqlDataAdapter da = new SqlDataAdapter(strquery,sqlcon);
DataSet ds = new DataSet();
da.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
byte[] barrImg = (byte[])dt.Rows[7]["image"];
MemoryStream mstream = new MemoryStream(barrImg);
pictureBox2.Image = Image.FromStream(mstream);
}
錯誤在哪一行發生? – Tim
什麼**列表**你的表'testimg'包含?很可能,您在訪問數據時只是拼錯了列名。 –