VB ADO sql question

Posted on 2003-02-24
Medium Priority
Last Modified: 2011-09-20
I am trying to add a new record to a table, and I am using the following code:

strSql = "INSERT INTO Rooms (RoomNo, Capacity, Style, Extension) values ("
        strSql = strSql + "" + txtRoomNo.Text + ","
        strSql = strSql + " " + txtCapacity.Text + ","
        strSql = strSql + " ‘" + cboStyle.Text + "‘,"
        strSql = strSql + " " + txtExtension.Text + ")"
cm = New OleDbCommand(strSql, cn)

which results in the following string[as an example]:
INSERT INTO Rooms (RoomNo, Capacity, Style, Extension) values (500, 600, ‘Meeting‘, 456)

and i get "operation error: no value given for one or more required parameters"

Any help is appreciated... Thanks


Question by:soulfulcat83
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 44

Accepted Solution

Arthur_Wood earned 160 total points
ID: 8010900
change this:

strSql = strSql + "" + txtRoomNo.Text + ","
       strSql = strSql + " " + txtCapacity.Text + ","
       strSql = strSql + " " + cboStyle.Text + ","
       strSql = strSql + " " + txtExtension.Text + ")"

to this:

strSql = strSql + txtRoomNo.Text + ","
       strSql = strSql + " " + txtCapacity.Text + ","
       strSql = strSql + " '" + cboStyle.Text + "',"
       strSql = strSql + " " + txtExtension.Text + ")"

the field delimiter for Text fields is a single quote ('), no the  character. also the "" at the beginning is un-necessary.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month12 days, 22 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question