 |
|
asp.net สอบถามโชวร์รูปจาก access ที่เป็น FileStream |
|
 |
|
|
 |
 |
|
ผมตันมากครับ ช่วยด้วย
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-05-01 22:51:38 |
By :
abeedin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Dim cn As New SqlConnection(strCn)
cn.Open()
'Retrieve BLOB from database into DataSet.
Dim cmd As New SqlCommand("SELECT BLOBID, BLOBData FROM BLOBTest ORDER BY BLOBID", cn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, "BLOBTest")
Dim c As Integer = ds.Tables("BLOBTest").Rows.Count
If c > 0 Then
'BLOB is read into Byte array, then used to construct MemoryStream,
'then passed to PictureBox.
Dim byteBLOBData As [Byte]() = New [Byte](-1) {}
byteBLOBData = DirectCast(ds.Tables("BLOBTest").Rows(c - 1)("BLOBData"), [Byte]())
Dim stmBLOBData As New MemoryStream(byteBLOBData)
pictureBox1.Image = Image.FromStream(stmBLOBData)
End If
cn.Close()
Code (C#)
SqlConnection cn = new SqlConnection(strCn);
cn.Open();
//Retrieve BLOB from database into DataSet.
SqlCommand cmd = new SqlCommand("SELECT BLOBID, BLOBData FROM BLOBTest ORDER BY BLOBID", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "BLOBTest");
int c = ds.Tables["BLOBTest"].Rows.Count;
if(c>0)
{ //BLOB is read into Byte array, then used to construct MemoryStream,
//then passed to PictureBox.
Byte[] byteBLOBData = new Byte[0];
byteBLOBData = (Byte[])(ds.Tables["BLOBTest"].Rows[c - 1]["BLOBData"]);
MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
pictureBox1.Image= Image.FromStream(stmBLOBData);
}
cn.Close();
Go to : VB.NET สอบถามวิธีการดึงรูปภาพที่บันทึกไว้(เป็น Binary data)ในฐานข้อมูลเอามาแสดงใน PictureBox ครับ
|
 |
 |
 |
 |
Date :
2012-05-02 06:25:25 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ คุณ mr.win
เเต่ผมหา pictureBox ใน webfromของผมไม่เจออ่ะครับ add เพิ่มยังไงครับ
ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-05-02 09:58:53 |
By :
abeedin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|