Dim arrPicture() As Byte
arrPicture = CType(ds.Tables("MyTable").Rows(0)("file"), Byte())
Dim ms As New MemoryStream(arrPicture)
Dim ms1 As New IO.StringReader("")
With Text3
.Image = Image.FromStream(ms)
.SizeMode = PictureBoxSizeMode.CenterImage
.BorderStyle = BorderStyle.Fixed3D
End With
Tag : - - - -
Date :
2009-03-20 18:24:51
By :
Chai
View :
1629
Reply :
1
No. 1
Guest
Code (VB.NET)
Imports System.Data
Imports MySql.Data.MySqlClient
Partial Class ViewImg
Inherits System.Web.UI.Page
Dim objConn As New MySqlConnection
Dim objCmd As MySqlCommand
Dim strConnString, strSQL As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
strConnString = "Server=localhost;User Id=root; Password=root; Database=mydatabase; Pooling=false;"
objConn.ConnectionString = strConnString
objConn.Open()
'*** DataTable ***'
Dim dtAdapter As MySqlDataAdapter
Dim dt As New DataTable
strSQL = "SELECT * FROM files WHERE FilesID = ?sFilesID "
dtAdapter = New MySqlDataAdapter(strSQL, objConn)
objCmd = dtAdapter.SelectCommand
objCmd.Parameters.Add("?sFilesID", MySqlDbType.Int32).Value = Request.QueryString("FilesID")
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
Response.ContentType = dt.Rows(0)("FilesType").ToString()
Response.BinaryWrite(dt.Rows(0)("FilesName"))
End If
dt = Nothing
End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
objConn.Close()
objConn = Nothing
End Sub
End Class