01.
02.
If
OpenImageFile.ShowDialog = Windows.Forms.DialogResult.OK
AndAlso
OpenImageFile.FileName <>
Nothing
Then
03.
04.
For
Each
file
As
String
In
OpenImageFile.FileNames
05.
Try
06.
Dim
pic
As
New
PictureBox
07.
pic.Image = Image.FromFile(file)
08.
Using stream
As
New
IO.MemoryStream
09.
pic.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
10.
strSQL =
"INSERT INTO picture(byte_pic,key_pic,note_pic)"
_
11.
&
"VALUES(@byte_pic,@key_pic,@note_pic)"
12.
cmd =
New
MySqlCommand(strSQL, ConnectionDB)
13.
cmd.Parameters.AddWithValue(
"@byte_pic"
, stream.GetBuffer())
14.
cmd.Parameters.AddWithValue(
"@key_pic"
,
"images1"
)
15.
cmd.Parameters.AddWithValue(
"@note_pic"
,
"note"
)
16.
Call
open_connection()
17.
cmd.ExecuteNonQuery()
18.
stream.Close()
19.
End
Using
20.
Catch
ex
As
Exception
21.
22.
End
Try
23.
Next
24.
End
If