作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我目前正在开发 vb.net。我已经使用 BLOB 数据类型将图像上传到 mysql。现在我需要将pdf文件上传到mysql。想知道pdf的图片上传代码是否相同。
这是我的图像上传代码。
'open file diaglog btn
Private Sub open_Click(sender As System.Object, e As System.EventArgs) Handles open.Click
Dim opf As New OpenFileDialog
opf.Filter = "Image File | *.jpg"
If opf.ShowDialog = DialogResult.OK Then
AxAcroPDF1.src = opf.FileName
text_file.Text = opf.SafeFileName
End If
End Sub
'save to my sql btn
Private Sub save_Click(sender As System.Object, e As System.EventArgs) Handles save.Click
MySqlConn = New MySqlConnection
MySqlConn.ConnectionString =
"server=localhost;userid=root;password=;database=printlmun"
Dim ms As New MemoryStream
PictureBox1.Image.Save(MS, PictureBox1.Image.RawFormat)
Dim command As New MySqlCommand("INSERT INTO `forms`(`name`, `price`, `img`) VALUES (@name,@text_price,@text_img)", MySqlConn)
command.Parameters.Add("@text_uname", MySqlDbType.VarChar).Value = text_uname.Text()
command.Parameters.Add("@text_price", MySqlDbType.VarChar).Value = text_price.Text
command.Parameters.Add("@text_img", MySqlDbType.Blob).Value = ms.ToArray()
MySqlConn.Open()
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("Image Inserted")
Else
MessageBox.Show("Image Not Inserted")
End If
MySqlConn.Close()
End Sub
最佳答案
BLOB 代表二进制大对象。在这种情况下,文件类型无关紧要。无论是图片、PDF、ZIP 文件等,都无关紧要。
是的,如果它是图像或 PDF,一旦位于字节数组中,代码是相同的。
关于mysql - vb.net上传pdf到mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48124857/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!