eddom Level: Big Cheese
 Registered: 14-03-2006 Posts: 24
|
Inserting Image into MySQL Database
Hi,
I need some guide about how to insert a image into a cell of MySQL Database, i had search through the internet, and finally i what i can conclude is, i cant use the PROCEDURE method cox i use the old version of MySQL. The situation would be, the picture had converted into a array of Byte:
Public Sub StorePicToDB(ByVal PicFile As Byte(), ByVal Length As Int32)
Dim Con As New Odbc.OdbcConnection
Dim Cmd As New Odbc.OdbcCommand
Dim StoreFile As New Odbc.OdbcParameter
Dim MyID As New Odbc.OdbcParameter
Con.ConnectionString = ConnectString
StoreFile.DbType = DbType.Binary
StoreFile.ParameterName = "@StoreFile"
StoreFile.Value = PicFile
MyID.DbType = DbType.String
MyID.ParameterName = "@MyID"
MyID.Value = "6"
Con.Open()
Cmd.Connection = Con
Cmd.Parameters.Add(StoreFile)
Cmd.Parameters.Add(MyID)
Dim Num As Integer
Num = Cmd.Parameters.Count
Cmd.CommandText = "INSERT INTO Card (ID,Name,Picture) VALUES(@MyID,'Test',@StoreFile)"
Cmd.ExecuteNonQuery()
Con.Close()
End Sub |
I failed with the code above, it does enter the record, but the field 'ID' and 'Picture' is NULL, so that mean the Command cant get the value of @MyID and @StoreFile. So i does tested to get how many Parameters i had in Cmd also, it return me that i got 2. Any idea on how to solve this?
|