Inserting images into MySql

  • Thread starter Thread starter feudalac!
  • Start date Start date
F

feudalac!

Hello.


How can I insert an image into MySQL database and later retrive it for
displaying on a form?


Thanks...
 
i have this for now
OFD1 is open file dialog


OFD1.Filter = "GIF|*.gif|JPG|*.jpg"
OFD1.ShowDialog()
If OFD1.FileName = "" Then Exit Sub
Dim StreamSlika As System.IO.FileStream
StreamSlika = New System.IO.FileStream(OFD1.FileName,
IO.FileMode.Open, IO.FileAccess.Read)
a.SetData("UPDATE tvrtke_zem_gr_ul_obj_kat_pro SET slika='" &
StreamSlika & "' WHERE pro_id='1'")

and the following error

Error 5 Operator '&' is not defined for types 'String' and
'System.IO.FileStream'. C:\Documents and Settings\username\My
Documents\Visual Studio
2005\Projects\AllMyHardware\AllMyHardware\Form1.vb 610 19 AllMyHardware
 
Cor Ligthert [MVP] izlupa:
Feudalac

In general contains this pages everything you need except the normal
datahandling with datasets.

http://www.vb-tips.com/default.aspx?ID=0bf3f72d-b722-459d-8a46-38b5a2f
7fdf0

I hope this helps,

Cor


Now I do this

(bytestream is byte)

DIM MySqlData = New System.Data.DataTable
MySqlAdapter.Fill(MySqlData)
MySqlData.Rows(0)("slika") = byteStream
MySqlAdapter.Update(MySqlData)

and i have the following error

Update requires a valid UpdateCommand when passed DataRow collection
with modified rows.
 
Creating an update command is of course the least that you have to do, for
Access or SQLserver I would use the commandbuilder in this case. Now you
have to do it yourself. I am not familiair with MySQL so maybe somebody else
can help you with that.

For SQL server that updata command could be as it is in this sample

http://www.vb-tips.com/default.aspx?ID=3405596d-4556-4aa8-be12-d7c12bbb3726

Cor

feudalac! said:
Cor Ligthert [MVP] izlupa:



Now I do this

(bytestream is byte)

DIM MySqlData = New System.Data.DataTable
MySqlAdapter.Fill(MySqlData)
MySqlData.Rows(0)("slika") = byteStream
MySqlAdapter.Update(MySqlData)

and i have the following error

Update requires a valid UpdateCommand when passed DataRow collection
with modified rows.

That is of course the least that you have to do, for Access or SQLserver I
would use the commandbuilder in this case. Now you have to do it yourself. I
am not familiair with MySQL so maybe somebody else can help you with that.

For SQL server that updata command could be as it is in this sample

http://www.vb-tips.com/default.aspx?ID=3405596d-4556-4aa8-be12-d7c12bbb3726

Cor
 
Cor Ligthert [MVP] izlupa:
Creating an update command is of course the least that you have to
do, for Access or SQLserver I would use the commandbuilder in this
case. Now you have to do it yourself. I am not familiair with MySQL
so maybe somebody else can help you with that.

For SQL server that updata command could be as it is in this sample

http://www.vb-tips.com/default.aspx?ID=3405596d-4556-4aa8-be12-d7c12bb
b3726

Cor

thanks...

you have been most helpful...
 
Back
Top