怎么在题目里添加图片到SQL数据库中
2008-04-08 09:44
239 查看
Public Class Form1Class Form1
Private db As New LzmTW.Data.SqlDatabase(".", "NorthWind")
Private Sub Button1_Click()Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SqlCreate As String = "CREATE TABLE Simple(ID int , Photo image, sex bit)"
db.Execute(SqlCreate)
End Sub
Private Sub Button2_Click()Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim table As New DataTable("Simple")
db.Load("Simple", table, New String() {"ID"})
Me.DataGridView1.DataSource = table
If table.Rows.Count = 0 Then Return
Dim row As DataRow = table.Rows(0)
Dim bytes() As Byte = CType(row(1), Byte())
Dim m As New System.IO.MemoryStream(bytes)
Dim t As New System.Drawing.Bitmap(m)
Me.PictureBox1.Image = t
End Sub
Private Sub Button3_Click()Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Using d As New OpenFileDialog
With d
.Multiselect = False
.Filter = "*.PNG|*.PNG"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Using r As New System.IO.BinaryReader(System.IO.File.Open(.FileName, IO.FileMode.Open))
Dim len As Integer = CInt(New System.IO.FileInfo(.FileName).Length)
Dim bytes(len - 1) As Byte
r.Read(bytes, 0, len)
Dim m As New System.IO.MemoryStream(bytes)
Dim t As New System.Drawing.Bitmap(m)
Me.PictureBox1.Image = t
Dim row As DataRow = CType(Me.DataGridView1.DataSource, DataTable).NewRow
row(0) = CType(Me.DataGridView1.DataSource, DataTable).Rows.Count + 1
row(1) = bytes
row(2) = False
CType(Me.DataGridView1.DataSource, DataTable).Rows.Add(row)
End Using
End If
End With
End Using
End Sub
Private Sub Button4_Click()Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
db.Update("Simple", CType(Me.DataGridView1.DataSource, DataTable), New String() {"ID"})
End Sub
Private Sub Button5_Click()Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
db.Execute("DROP TABLE Simple")
End Sub
End Class
相关文章推荐
- 怎么才能编辑pdf文件并添加图片
- 求解答??怎么二次清除通过input添加显示的img图片
- 怎么在CAD里面添加图片
- 怎么给图片或视频添加夜视效果?
- Andorid中如果在TextView中用drawable添加图片,怎么能改变图片与文字的距离
- 怎么使用Picasso添加图片
- 怎么实现EDIUS中添加的图片素材一样大
- Qt 怎么添加图片文件?
- 登入页面添加图片有重复页面出现怎么办
- Qt 怎么添加图片文件?
- 【微信小程序】图片被压扁怎么办?在image中添加 mode="widthFix"
- 怎么往JFrame中添加图片
- textbox在c#中怎么添加背景图片
- html怎么添加背景图片
- 怎么获取WORD的中的添加的很多张图片
- pdf文档图片怎么添加,文字怎么修改
- 怎么在浏览器网站前添加图标(图片)
- pdf文件怎么添加图片,文字怎么修改
- 大神们有知道图片上怎么添加多个可以随意拖动的标记吗?
- 怎么在gif图片上添加文字