Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:44:19+00:00 2026-06-11T20:44:19+00:00

I am using OleDbParameter to build an OleDbCommand to INSERT a record into MS

  • 0

I am using OleDbParameter to build an OleDbCommand to INSERT a record into MS Access. But I get Syntax Error when I am executing the statement. If anyone can see what is preventing the query successfully executing it would be a huge help.

This is my code:

string query = "INSERT INTO Customer (customerID, date, time, telephone, fax,"
    + "name, sourceAddress, destAddress, via1, via2, via3,"
    + "priority, ourReference) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

OleDbCommand oleDbCommand = new OleDbCommand(query, oleDbConnection);

OleDbParameter customerID = new OleDbParameter();
OleDbParameter date = new OleDbParameter();
OleDbParameter time = new OleDbParameter();
OleDbParameter telephone = new OleDbParameter();
OleDbParameter fax = new OleDbParameter();
OleDbParameter name = new OleDbParameter();
OleDbParameter sourceAddress = new OleDbParameter();
OleDbParameter destAddress = new OleDbParameter();
OleDbParameter via1 = new OleDbParameter();
OleDbParameter via2 = new OleDbParameter();
OleDbParameter via3 = new OleDbParameter();
OleDbParameter priority = new OleDbParameter();
OleDbParameter ourReference = new OleDbParameter();

oleDbCommand.Parameters.Add(customerID);
oleDbCommand.Parameters.Add(date);
oleDbCommand.Parameters.Add(time);
oleDbCommand.Parameters.Add(telephone);
oleDbCommand.Parameters.Add(fax);
oleDbCommand.Parameters.Add(name);
oleDbCommand.Parameters.Add(sourceAddress);
oleDbCommand.Parameters.Add(destAddress);
oleDbCommand.Parameters.Add(via1);
oleDbCommand.Parameters.Add(via2);
oleDbCommand.Parameters.Add(via3);
oleDbCommand.Parameters.Add(priority);
oleDbCommand.Parameters.Add(ourReference);

customerID.Value = 4;
date.Value = "01/01/01";
time.Value = "01:01:01";
telephone.Value = 01010101;
fax.Value = 01010101;
name.Value = "test 4";
sourceAddress.Value = "test 4 source address";
destAddress.Value = "test 4 dest address";
via1.Value = "test 4 via 1";
via2.Value = "test 4 via 2";
via3.Value = "test 4 via 3";
priority.Value = 1;
ourReference.Value = "test 4 ref";

MessageBox.Show(oleDbCommand.CommandText.ToString());

OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(oleDbCommand);

oleDbCommand.CommandText = query;

oleDbConnection.Open();

oleDbCommand.ExecuteNonQuery();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:44:20+00:00Added an answer on June 11, 2026 at 8:44 pm

    The fields date and time are reserved words for JET/Access, so you should encapsulate them in square brackets. (this is the real origin of the Syntax Error message)

    "INSERT INTO Customer (customerID, [date], [time], telephone, fax, name, " + 
    "sourceAddress, destAddress, via1, via2, via3," + "priority, ourReference) VALUES " + 
    "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 
    

    Of course the number of parameters should match. (12 placeholder vs 13 fields/parameters, add another placeholder ?), but this will give another error message, not the syntax error stated

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was trying to insert values into an Access database using a parameterized query:
I read data from MS Access using C#. But get the OleDbException trying to
Im currently using OleDBCommand.ExecuteNonQuery (repeatedly called) to insert as much as 350,000 rows into
I am trying to insert records into Access table from SQL Server table. For
Using C#, I want to show the image in the Access column but failed
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
Using the Redis info command, I am able to get all the stats of
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
I am new to MS Access 2007 and I am creating an application using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.