国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

怎樣在vb.net中將圖片存入SQL Server 2000并能讀出來使用?

2019-11-18 16:43:15
字體:
供稿:網(wǎng)友

數(shù)據(jù)庫中建一個Img表,其中包含一個Img字段,類型為Image或Binary
'將Bytes存入數(shù)據(jù)庫
Dim Stream As New IO.MemoryStream
PictureBox1.Image.Save(Stream, System.Drawing.Imaging.ImageFormat.Bmp)
Stream.Flush()
Dim Bytes As Byte() = Stream.ToArray
Dim SQL As String = "insert into Img values (@bytes) "
Dim command As New SqlClient.SqlCommand(SQL, Connection)
command.Parameters.Add("@bytes", SqlDbType.Binary).Value = Bytes
command.ExecuteNonQuery

'讀取
Dim Command As New SqlClient.SqlCommand(SQL, Connection)
Dim Reader As SqlClient.SqlDataReader = Command.ExecuteReader()
Dim Bytes as Byte()=Reader.Item("Img")
Dim mStream As New IO.MemoryStream
mStream.Write(Bytes, 0, Bytes.Length)
mStream.Flush()
Dim Img As New Bitmap(mStream)
PictureBox1.Image = Img


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 临城县| 濮阳市| 福州市| 板桥市| 镶黄旗| 丁青县| 尚志市| 巢湖市| 乐陵市| 灵武市| 睢宁县| 松原市| 凤冈县| 交城县| 曲阜市| 巴林右旗| 阜城县| 汾西县| 吴桥县| 罗定市| 巍山| 新干县| 天台县| 吐鲁番市| 都安| 南靖县| 土默特右旗| 韶山市| 台东市| 乳山市| 崇左市| 云龙县| 吉木乃县| 伽师县| 习水县| 株洲市| 邹平县| 睢宁县| 津南区| 海盐县| 甘肃省|