In my present project I am using VB.net with SQL Server2000.(It is a Client Server not web based)
How to uplaod the images into the database.
How to retrieve the image from the database into a picturebox.
Someone having an idea, in this regard is most welcome.
if the image is embedded in the database it is probably binary. You have to create a temp binary file from the data read in from the database, then you load that into the image in your picture box.
this is a question I started looking for answer too and has been bugging me since yesterday.. Finally found out how to make it work.
Your answer could look something like ..
Dim dA As New SqlClient.SqlDataAdapter("SELECT BLOB FROM BLOBS", cn)
Dim dt As New DataTable
Dim x As Image
dA.Fill(dt)
Dim bytImage(dt.Rows(0)(0).length - 1) As Byte
bytImage = dt.Rows(0)(0)
Dim memStream As New IO.MemoryStream(bytImage)
PictureBox1.Image = Image.FromStream(memStream) 'Image.FromFile("C:\Documents and Settings\Administrator\My Documents\My Pictures\InDotLogoB.jpg"
Dim fs As New IO.FileStream("C:\Documents and Settings\Administrator\My Documents\My Pictures\InDotLogoB.jpg", IO.FileMode.Open, IO.FileAccess.Read)
Dim imageData(fs.Length) As Byte
Dim intlen As Integer = fs.Length
Dim cn As New SqlClient.SqlConnection("server=(local);database=blobstuff;trusted_connection=yes"
fs.Read(imageData, 0, fs.Length)
fs.Close()
Dim cm As New SqlClient.SqlCommand("AddBlob", cn)
cm.Parameters.Add("@blob", SqlDbType.Image)
cm.Parameters("@blob".Direction = ParameterDirection.Input
cm.Parameters("@blob".Value = imageData
cm.CommandType = CommandType.StoredProcedure
cn.Open()
cm.ExecuteNonQuery()
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.