如何使用vb.net将图片插入sql数据库? [英] How to insert picture into a sql database using vb.net?
本文介绍了如何使用vb.net将图片插入sql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用vb.net将图像插入到sqldatabse中。我使用相同的概念将数据插入数据库并且它工作但当我尝试使用相同的概念插入图像时,我的程序说命令执行期间发生致命错误。有人可以告诉我如何解决错误吗?
I am trying to insert an image into a sqldatabse using vb.net. I have used the same concept to insert data into database and it worked but when i try to insert image using the same concept then my program says "Fatal error occurred during command execution". Can someone advise me how i can fix the error?
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MysqlConn = New MySqlConnection
MysqlConn.ConnectionString =
"server=localhost;userid=***;password=*******;database=database3"
Dim READER As MySqlDataReader
Try
MysqlConn.Open()
Dim Query As String
Query = "Insert into database3.trial (id,Image) values ( '" & TextBox1.Text & "', @Image)"
COMMAND = New MySqlCommand(Query, MysqlConn)
READER = COMMAND.ExecuteReader
MessageBox.Show("DATA SAVED")
MysqlConn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
End Sub
推荐答案
您没有添加和设置@Image
参数。当你在它的时候,也可以使用id
的参数。
You didn't add and set the@Image
parameter. And while you're at it, use a parameter for theid
as well.
这篇关于如何使用vb.net将图片插入sql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文