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 7756867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:55:57+00:00 2026-06-01T12:55:57+00:00

I’m having great difficulty in inserting a record to my access database. I’ve tried

  • 0

I’m having great difficulty in inserting a record to my access database. I’ve tried the query in access and it inserts fine. I’ve also tried the query in the query builder and it works too however if I run this code it claims to have inserted the record into the database, but when I check the database there is no sign of a new record.

      oleDbCommandCreateAppointment.Parameters["appointmentDate"].Value = "06/04/2012";
        oleDbCommandCreateAppointment.Parameters["timeSlotID"].Value ="21";
        oleDbCommandCreateAppointment.Parameters["startTime"].Value = "09:00";
        oleDbCommandCreateAppointment.Parameters["employeeID"].Value ="1";
        oleDbCommandCreateAppointment.Parameters["clientID"].Value ="1";
        oleDbCommandCreateAppointment.Parameters["assistantID"].Value ="1";
        oleDbCommandCreateAppointment.Parameters["appointmentType"].Value = "Quote";
        oleDbCommandCreateAppointment.Parameters["appointmentFlag"].Value = "Booked";

        try
        {
            oleDbConnection.Open();
            int rows = oleDbCommandCreateAppointment.ExecuteNonQuery();

            MessageBox.Show("Rows inserted " + rows.ToString());

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
        finally
        {
            oleDbConnection.Close();
        }

SQL Command

INSERT INTO tblAppointments
                     (appointmentDate, timeSlotID, startTime, employeeID, clientID, assistantID, appointmentType, appointmentFlag)
  VALUES        (?, ?, ?, ?, ?, ?, ?, ?)

Many thanks

  • 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-01T12:55:59+00:00Added an answer on June 1, 2026 at 12:55 pm

    You need to associate the connection with the db command object:

    oleDbConnection.Open();
    oleDbCommandCreateAppointment.Connection = oleDbConnection;
    int rows = oleDbCommandCreateAppointment.ExecuteNonQuery();
    

    EDIT – This may have has to do with the parameter ordering, try this:

    oleDbCommandCreateAppointment.Parameters[0].Value = "06/04/2012";
    oleDbCommandCreateAppointment.Parameters[1].Value = "21";
    oleDbCommandCreateAppointment.Parameters[2].Value = "09:00";
    oleDbCommandCreateAppointment.Parameters[3].Value = "1";
    oleDbCommandCreateAppointment.Parameters[4].Value = "1";
    oleDbCommandCreateAppointment.Parameters[5].Value = "1";
    oleDbCommandCreateAppointment.Parameters[6].Value = "Quote";
    oleDbCommandCreateAppointment.Parameters[7].Value = "Booked";
    

    NOTE – Something I learned while working on this, you can’t use named parameters with ODBC and OleDB commands, only positional parameters (see Table 6) and this link points out that the OleDbCommand object only supports positional parameters when the command type is Text. Positional parameters are order dependent.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a reasonable size flat file database of text documents mostly saved in
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.