 |
|
นำไฟล์รูปภาพใน SQL Server 2005 มาแสดงใน PictureBox VB.NET |
|
 |
|
|
 |
 |
|
ลองดูกระทู้นี้ครับ
Code (VB.NET)
connection.Open();
SqlCommand command1 = new SqlCommand("select imgfile from myimages where imgname=@param", connection);
SqlParameter myparam = command1.Parameters.Add("@param", SqlDbType.NVarChar, 30);
myparam.Value = txtimgname.Text;
byte[] img = (byte[])command1.ExecuteScalar();
MemoryStream str = new MemoryStream();
str.Write(img, 0, img.Length);
Bitmap bit = new Bitmap(str);
Response.ContentType = "image/jpeg";
bit.Save(Response.OutputStream, ImageFormat.Jpeg);
connection.Close();
Go to : สอบถามวิธีการดึงรูปภาพที่บันทึกไว้(เป็น Binary data)ในฐานข้อมูลเอามาแสดงใน PictureBox ครับ
|
 |
 |
 |
 |
Date :
2011-07-23 08:33:39 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มำไมไม่เก้บเป็นชื่อไฟล์รูปเอาอะครับ เวลาเรียกใช้น่าจะง่ายกว่านะครับ
Code (VB.NET)
With dgvEquipmentList
PictureBox.ImageLocation = Application.StartupPath & "ชื่อ Folder\" & .Rows.Item(e.RowIndex).Cells(7).Value.ToString()
End With
|
 |
 |
 |
 |
Date :
2011-07-23 21:38:05 |
By :
slurpee55555 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโค๊ดที่บันทึกรูปทาง Picture Box ลง Database หน่อยจ้า VB น๊า
|
 |
 |
 |
 |
Date :
2011-07-23 23:45:49 |
By :
idearkung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกความเห็นครับ
|
 |
 |
 |
 |
Date :
2011-08-11 16:34:51 |
By :
suvivor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Using myConnection As New OleDbConnection(strConnection)
myConnection.Open()
Dim strSql As String = "SELECT PICTURE FROM MT_IMAGE"
Try
Using myCommand As New OleDbCommand(strSql, myConnection)
myCommand.CommandType = CommandType.Text
Using myDataReader As OleDbDataReader = myCommand.ExecuteReader()
myDataReader.Read()
Dim ImageBytes As Byte() = CType(myDataReader(0), Byte())
Dim ms As New MemoryStream(ImageBytes)
Dim img As Image = Image.FromStream(ms)
picShow.Image = img
End Using
End Using
Catch ex As Exception
MessageBox.Show(ex.Message, "Error")
End Try
End Using
|
 |
 |
 |
 |
Date :
2013-04-01 17:11:50 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|