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

  • SEARCH
  • Home
  • 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 8621715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:52:51+00:00 2026-06-12T06:52:51+00:00

When I try to insert some data in an MS Access DB, the data

  • 0

When I try to insert some data in an MS Access DB, the data is not inserted. Is something missing in my code?

This is the code

public void Toevoegen(
        int nummer, string voornaam, string achternaam, 
        string gsm, string nationaliteit, string adres, 
        DateTime geboorteDatum, string geboortePlaats, DateTime inschrijvingsDatum, 
        string sporten, int postCode, string gemeente, string klasse,
        Boolean competitie, string ziektes, string email)
    {
        try
        {
            string query = @"INSERT INTO Lid "
                + "VALUES ("
                + "@Lid_ID, "
                + "@Lid_VoorNaam, "
                + "@Lid_AchterNaam, "
                + "@Lid_Email, "
                + "@Lid_GeboorteDatum, "
                + "@Lid_InschrijvingsDatum, "
                + "@Lid_Nationaliteit, "
                + "@Lid_GeboortePlaats, "
                + "@Lid_Adres, "
                + "@Lid_PostCode, "
                + "@Lid_Gemeente, "
                + "@Lid_GSM, "
                + "@Lid_BeoefendeSporten, "
                + "@Lid_Competitie, "
                + "@Lid_KickKlasse, "
                + "@Lid_Ziektes)";

            OleDbCommand command = new OleDbCommand(query);
            command.Parameters.Add("@Lid_ID", OleDbType.Numeric).Value = nummer;
            command.Parameters.Add("@Lid_VoorNaam", OleDbType.Char).Value = voornaam;
            command.Parameters.Add("@Lid_Achternaam", OleDbType.Char).Value = achternaam;
            command.Parameters.Add("@Lid_Email", OleDbType.Char).Value = email;
            command.Parameters.Add("@Lid_GeboorteDatum", OleDbType.Date).Value = geboorteDatum;
            command.Parameters.Add("@Lid_InschrijvingsDatum", OleDbType.Date).Value = inschrijvingsDatum;
            command.Parameters.Add("@Lid_Nationaliteit", OleDbType.Char).Value = nationaliteit;
            command.Parameters.Add("@Lid_GeboortePlaats", OleDbType.Char).Value = geboortePlaats;
            command.Parameters.Add("@Lid_Adres", OleDbType.Char).Value = adres;
            command.Parameters.Add("@Lid_PostCode", OleDbType.Numeric).Value = postCode;
            command.Parameters.Add("@Lid_Gemeente", OleDbType.Char).Value = gemeente;
            command.Parameters.Add("@Lid_GSM", OleDbType.Char).Value = gsm;
            command.Parameters.Add("@Lid_BeoefendeSporten", OleDbType.Char).Value = sporten;
            command.Parameters.Add("@Lid_Competitie", OleDbType.Boolean).Value = competitie;
            command.Parameters.Add("@Lid_KickKlasse", OleDbType.Char).Value = klasse;
            command.Parameters.Add("@Lid_Ziektes", OleDbType.Char).Value = ziektes;
            conn.executeInsertQuery(command);
        }
        catch (Exception error)
        {
            System.Windows.Forms.MessageBox.Show(error.Message);
        }
    }

—

public bool executeInsertQuery(OleDbCommand _command)
    {
        OleDbCommand myCommand = new OleDbCommand();
        try
        {
            myCommand.Connection = openConnection();
            //myCommand.CommandText = _query;
            //myCommand.Parameters.AddRange(dbParameter);
            myAdapter.InsertCommand = _command;
            myCommand.ExecuteNonQuery();
        }
        catch (OleDbException e)
        {
            Console.Write("Error - Connection.executeInsertQuery - Query: " 
                + _command.CommandText + " \nException: \n" + e.StackTrace.ToString());
            return false;
        }
        finally
        {
        }
        return true;
    }

Thank you in advance.

  • 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-12T06:52:52+00:00Added an answer on June 12, 2026 at 6:52 am

    Problem will be here:

    myAdapter.InsertCommand = _command;
    myCommand.ExecuteNonQuery();
    

    You assign command to myAdapter but then execute myCommand which is empty.

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

Sidebar

Related Questions

I am trying to insert some data. It is not getting inserted in the
I have problem when I try insert some data to Informix TEXT column via
I'm using Hibernate 3.2.1 and database SQLServer2000 while I'm try to insert some data
I get the following error message when I try to INSERT some data: SQLSTATE[23000]:
I am trying to INSERT some data in ms access database using jsp but
If I try this statement: INSERT INTO TerminalEventChild (id,stringValue) VALUES (64,'version123|'); MySQL fail with
On my activity, im getting some big data from web, and while getting this
Good evening. I am doing a basic exercise to insert data into an Access
I need to insert some data and I'm doing it by calling WCF from
I need some help with creating an insert statement for an Access 2007 database

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.