How to insert data in from C# to Ms Access BE


I’m now stuck with how to get the data from window forms application into the MS access Back end (BE)
The back end has the following tables in Ms Access 2007:
(1)      tblInvoices with the following controls
•      CustomerID (ComboBox)
•      SaleTime (Txt)
•      SalesMan (Txt)
(2)      Sub table (tblSaleslinedetails) linked to the tblinvoice has the following controls:
•      PronductName (ComboBox)
•      WarehouseName(ComboBox)
•      SalesQty (Txt)
•      Price (Txt)
Now the question is, how do I complete the coding in C# form to insert the data in the Back end tables above. Below is the suggested string:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Jet OLEDB:Database Password=MyDbPassword;

We are required to use C# form because of the requirements to interface the POS program which require that our project in C# should have the essential files in the same directory  

Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScDirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
[..] requirements to interface the POS program [..]
This is important: What part in the POS is your program?

Then: You normally use OleDb.

namespace ConsoleCS
    using System;
    using System.Data.OleDb;

    public class Program
        public static void Main(string[] args)
            string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Temp\test.accdb";
            string insertSql = "INSERT INTO yourTable ( Payload ) VALUE ( 1 );";
            using (OleDbConnection connection = new OleDbConnection(connectionString))
                OleDbCommand command = new OleDbCommand(insertSql);
                command.Connection = connection;
                catch (Exception ex)


Open in new window

Caveat: do you work on a 32-bit or 64-bit machine? In the second case you need to install the ACE.OLDB 64-bit driver manually.

p.s. Asking a question like
[..] how do I complete the coding in [..]
is pretty unkind without posting your actual code. Cause concise code samples showing your problem has two advantages. 1) we have the same code base to talk about. 2) it already shows that you can abstract and isolate problems.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.