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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:56:18+00:00 2026-06-04T00:56:18+00:00

I am trying to Update a table in an access database from C#. It

  • 0

I am trying to Update a table in an access database from C#.

It is a .mdb type database.

here is the connection string I am using.
public MainWindow() {

InitializeComponent();

OleDbConnection cn= new OleDbConnection();}
cn.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" 
    + "C:\Users\Angela\Documents\Visual Studio 2010\Projects\Havnefoged11.mdb;" 
    + "User Id=;Password=;";

cn.Open();

Application.Current.Properties["DBConnection"] = cn;

The file is in the correct folder C:\Users\Angela\Documents\Visual Studio 2010\Projects

 private void button1_Click_1(object sender, RoutedEventArgs e)
    {

 OleDbConnection conn =             

 (OleDbConnection)Application.Current.Properties["DBConnection"];
 //Below are the values i want to put into the database 
 String dybde = Dybde.Text;
 String bredde = Bredde.Text;
 String plads = PladsNummer.Text;

String StrSQL = 
    "INSERT INTO Bådpladser (Plads_nummer,Bredde,Dybde) VALUES (´´"+ plads
        + "´,´" 
        + bredde
        + "´," 
        + dybde+");";

  OleDbCommand InsertCommand = new OleDbCommand(StrSQL, conn);

   InsertCommand.ExecuteNonQuery();
    }

I then get the error
OleDBException was unhandled NO value given for one or more parameters

I have gone in and changed all the fields in the database to be text
I have checked the field names they are correct.
The ldb file comes when I initialise the program.
but as soon as I press the button I get the error.

Any ideas?

Ps
I have included the

  using System.Data;
   using System.Data.OleDb;
  • 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-04T00:56:20+00:00Added an answer on June 4, 2026 at 12:56 am

    As others pointed out, you are open to SQL injection attacks. You should use parameters. The reason it is probably failing is that the content of the strings you are inserting may contain a “?” and “?” is implied as “I am expecting a parameter here” and is what is making it choke.

    Try changing to

    String StrSQL = "INSERT INTO Bådpladser (Plads_nummer, Bredde, Dybde ) VALUES ( ?, ?, ? )";
    OleDbCommand InsertCommand = new OleDbCommand(StrSQL, conn )
    InsertCommand.Parameters.AddWithValue( "yourFirstParm", plads );
    InsertCommand.Parameters.AddWithValue( "yourSecondParm", bredde );
    InsertCommand.Parameters.AddWithValue( "yourThirdParm", dybde );
    

    THEN, execute it, but NOTE: The parameters must be added in the same sequence as your “?” place-holders.

    Also, it may be that your backend DOES support named parameters and not “?” values… if so, you may need to adjust to something like

    String StrSQL = "INSERT INTO Bådpladser (Plads_nummer, Bredde, Dybde ) "
          + "VALUES ( @parmPlads, @parmBredde, @parmDybde )";
    OleDbCommand InsertCommand = new OleDbCommand(StrSQL, conn )
    InsertCommand.Parameters.AddWithValue( "@parmPlads", plads );
    InsertCommand.Parameters.AddWithValue( "@parmBredde", bredde );
    InsertCommand.Parameters.AddWithValue( "@parmDybde", dybde );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update a record from an Ms-Access table with VB.NET and ASP.NET.
I'm trying to update a table in Access database. But when I debug I
I am trying to update table A with data from table B. I thought
Here is my trial query. I am trying to update TABLE1 table with it's
I am trying to update a field in a table with data from another
I am coming from a novice database programmer background, mainly using MS Access for
I have a DataGridView that displays data from a MS Access database. I'm using
I'm trying to update my database i.e. a MS Access file, I want to
I am trying to update an Access database with a vb script by putting
I'm trying to update one table based on values in another table. What's wrong

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.