Store Image From Picture Box To SQL SERVER
My New Task
Save Image from Picturebox to Sql Server Table.
Dim stream As New MemoryStream()
picEmp.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim oImgByteArray() As Byte
oImgByteArray() = stream.ToArray
Dim SQLCmd As New SqlCommand
SQLCmd.Connection = cnSQL
SQLCmd.Parameters.Add(New SqlParameter("@Img", SqlDbType.Image)).Value = oImgByteArray
SQLCmd.CommandText = "Insert Into CMS.mastImageStoreage (Img) Values (@Img)"
SQLCmd.ExecuteNonQuery()
stream.close
SQLCmd.Dispose
Note : This is why love working on .net platform. If you were suppose perform same in VB 6.0. Physical file is need in path and than only you can save. Think bring same from database. You have create physical file in drive and load it from there.
Comments
Post a Comment