1

I am trying to insert data to Access 365 in .net core API. Below is what I did to insert the data, but I am getting an error saying that :

The type or namespace name 'OleDbConnection' does not exist in the namespace 'System.Data.OleDb' (are you missing an assembly reference?)

I added the assembly reference to :

    using System.Data;
    using System.Data.Odbc;
    using System.Data.OleDb

Below is my partial C# code:

  public void PrimeAccessRules()
        {
            List<RecLoad> recList = new List<RecLoad>();
            recList = getPrimeData();
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
        @"Data source= C:\Users\test\recload.accdb";

            try
            {
                conn.Open();
            }
        }

The error is coming right on this line:

System.Data.OleDb.**OleDbConnection**

saying that OleDbConnection does not exists

Any help will be highly apprecaited.

2
  • Have you added the System.Data.OleDb package? Commented Apr 4, 2020 at 22:16
  • No, I didnt. I just added it and the error is gone. I thought, by adding System.Data.oledb is enough Thanks for the help. error is gone now. Commented Apr 4, 2020 at 22:20

1 Answer 1

1

The types in the System.Data.OleDb namespace are part of the System.Data assembly in .NET Framework, but they're not included in .NET Core or .NET Standard. Since you're targetting one of the latter two (.NET Core), you'll need to add the System.Data.OleDb package to your project.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.