|
|
#1 |
|
New Member
Join Date: Nov 06
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 |
|
Hyperactive Member
Join Date: Apr 05
Location: Indiana
Posts: 450
![]() |
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 |
|
New Member
Join Date: Nov 06
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 |
|
.NUT
Join Date: May 05
Location: Sydney, Australia
Posts: 61,542
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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)
__________________
![]() 2007-2010 Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs MSDN "How Do I?" Videos: VB | C# VBForums Database Development FAQ My CodeBank Submissions: VB (Nullable Data Extensions *NEW*) (Serial Code TextBox *NEW*) | C# (ForumAccount has translated some of my VB submissions to C#) My Blog: Defining and Raising Custom Events | Using Parameters in ADO.NET | Keyboard Events *NEW* |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|