Results 1 to 5 of 5

Thread: [RESOLVED][2005] MYSQL parameter problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    87

    Resolved [RESOLVED][2005] MYSQL parameter problem

    As the title says:

    I got a problem using parameters in the mysql.data.client.mysqlcommand


    This is my code:

    Code:
    Dim querystring As String
            querystring = "INSERT INTO tblpicture(data) VALUES(@Picture)"
            Dim QueryT As New MySqlCommand(querystring, connection)
            QueryT.Parameters.Add("@Picture", MySqlDbType.String)
            QueryT.Parameters(0).Value = "hello"
            Console.WriteLine(QueryT.Parameters.Item(0).Value)
            Console.WriteLine(QueryT.CommandText)
    QueryT.ExecuteNonQuery() ' causes the error
    error: #23000Column 'data' cannot be null

    Data column i set was set to NOT NULL

    I got truely no idea what is goeing wrong here.

    I am planning on saving banairy data in the database and saw this as the only solution. It doesnt matter with what kind of datatype i try it, it wont work. So this was for people who wanted to ask why i dont just add the string in de string.

    These are the 2 lines from the output.:

    Code:
    hello
    INSERT INTO tblpicture(data) VALUES(@Picture)
    So the parrams realy work as you see. I can read them out if i want to.
    But the problem is that the value is not sended to the database.

    Is there someone that can help me with it?

    Greets
    Last edited by ovanwijk; Jan 2nd, 2008 at 06:31 AM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [2005] MYSQL parameter problem

    QueryT.prepare()

    Use the prepare statement before executing the query. This should fix it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] MYSQL parameter problem

    I don't think MySQL supports "@" as a prefix for parameters does it? That's specifically for SQL server. I think MySQL uses ":" although I'm not 100% sure as I've never used MySQL. I'm sure there would be MySQL/ADO.NET examples on the Web that would tell you.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [2005] MYSQL parameter problem

    I have seen ?,@ and :. They use @ in one part of their documentation and ? in others - a little constancy might be helpful

    http://dev.mysql.com/doc/refman/5.0/...parameter.html
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2007
    Posts
    87

    Re: [2005] MYSQL parameter problem

    ty ty people.
    The problem was that i needed '?' instead of '@'
    So thnx a lot. This one is solved.

    Greets

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width