在数据库中建一个img表,其中包含一个img字段,类型为Image或Binary
'将Bytes存入数据库Dim Stream As New IO.MemoryStreamPictureBox1.Image.Save(Stream,System.Drawing.Imaging.ImageFormat.Bmp)Stream.Flush()Dim Bytes As Byte() = Stream.ToArrayDim sql As String = "insert into img values (@bytes) "Dim command As New sqlClIEnt.sqlCommand(sql,Connection)command.Parameters.Add("@bytes",sqlDBType.Binary).Value = Bytescommand.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.MemoryStreammStream.Write(Bytes,Bytes.Length)mStream.Flush()Dim img As New Bitmap(mStream)PictureBox1.Image = img总结
以上是内存溢出为你收集整理的vb.net中将图片存入SQL Server 2000并能读出来使用全部内容,希望文章能够帮你解决vb.net中将图片存入SQL Server 2000并能读出来使用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)