Results 1 to 4 of 4

Thread: Oledb insert prob

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    13

    Oledb insert prob

    I'm using the query builder inside visual studio to insert some data into database, the problem is that it keeps giving me an error saying: Error in values list in INSERT INTO clause. Unable to parse query text.

    Here's the 'exact' SQL command that I am using, could someone please tell me where I am going wrong: INSERT INTO Accounts (customerID, balance, blocked, PIN) VALUES (@ customerID, @ balance, @ blocked, @ PIN)

    Thanks for any help.

  2. #2
    Hyperactive Member
    Join Date
    Apr 2005
    Location
    Indiana
    Posts
    451

    Re: Oledb insert prob

    Your SQL is correct, but you have to set your parameters. I don't use query builder, so I am not sure if you can do that in the query builder.

    In code it would look something like this, depending on your database, and what version of Visual Basic you are using.

    Command.Parameters.add("@customerID", MyDataType).Value = MyValue

    Hope that helps to get you at least half way there.
    Ben


    Using Visual Basic 2005/2008

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    13

    Re: Oledb insert prob

    I managed to get rid of the error with the query builder by missing out the '@' (but I'm not sure if this is the correct way of doing it) form the SQL command but now I get an error saying: parameter customerID has no default value?

    I have also set parameter collection to the right values.

    Anyone have any suggestions?

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

    Re: Oledb insert prob

    You should not remove the "@" form your parameter names. What you need to do is get rid of the spaces. The "@" is part of the parameter name, so it should be:
    Code:
    INSERT INTO Accounts (customerID, balance, blocked, PIN) VALUES (@customerID, @balance, @blocked, @PIN)
    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

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