borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (url\'s on command buttons)Next Topic (Console inside App...) New Topic New Poll Post Reply
AndreaVB Forum : VB.Net : Inserting Image into MySQL Database Solved Topic
Poster Message
eddom
Level: Big Cheese

Registered: 14-03-2006
Posts: 24

icon 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?

26-04-2006 at 05:56 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: Inserting Image into MySQL Database

Hope the article below helps.

http://www.vbcity.com/forums/topic.asp?tid=74665&highlight=fabulous

Steve  

26-04-2006 at 08:33 AM
View Profile Send Email to User Show All Posts | Quote Reply
eddom
Level: Big Cheese

Registered: 14-03-2006
Posts: 24
icon Re: Inserting Image into MySQL Database

Thanks,
     My problem solve, is actually the ODBC connector problem, i switch to MySql/Net connector and problem is solved with the same code i posted.

27-04-2006 at 12:52 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB.Net : Inserting Image into MySQL Database Solved Topic
Previous Topic (url\'s on command buttons)Next Topic (Console inside App...) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder