To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Apr 4th, 2007, 06:41 PM   #1
JENKINS
New Member
 
Join Date: Nov 06
Posts: 13
JENKINS is an unknown quantity at this point (<10)
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.
JENKINS is offline   Reply With Quote
Old Apr 4th, 2007, 06:56 PM   #2
Krenshau
Hyperactive Member
 
Join Date: Apr 05
Location: Indiana
Posts: 450
Krenshau  is on a distinguished road (40+)
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
Krenshau is offline   Reply With Quote
Old Apr 4th, 2007, 07:15 PM   #3
JENKINS
New Member
 
Join Date: Nov 06
Posts: 13
JENKINS is an unknown quantity at this point (<10)
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?
JENKINS is offline   Reply With Quote
Old Apr 4th, 2007, 07:55 PM   #4
jmcilhinney
.NUT
 
jmcilhinney's Avatar
 
Join Date: May 05
Location: Sydney, Australia
Posts: 61,542
jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)
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*
jmcilhinney is online now   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:23 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.