How to modify MS Access database properties collection (not data!) from a C# program?

What is the best way to access Microsoft Access (sorry!) Database object's properties (like in CurrenrDB.Properties) from C# MSVS 2010 please?

(Not essential: In fact I want to get rid of *Replication* in a few dozen databases "on demand". Replication is not in use for a few years, and it was OK for MS Access prior to 2013. Access 2013 rejects databases with this feature.)
LVL 1
midfdeAsked:
Who is Participating?
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.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You generally use DAO to do this. I don't have C# code for that, but from VBA:

Dim dbs As DAO.Database
Set dbs = OpenDatabase("path to db")

Dim prp As DAO.Property

For each prp in dbs.Properties
  Debug.Print prp.Name
Next

I'm not sure exactly how you'd go about removing replication, however. Might be simplest to just create a new, blank database and import all of the Access objects there. You can do that with DAO as well.
0
midfdeAuthor Commented:
Thanks, great!
But I am expecting an answer to my question, in C#, not VBA please.
0
midfdeAuthor Commented:
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
using Microsoft.Office.Interop.Access;
using Microsoft.Office.Interop.Access.Dao;
namespace testPiaCs{
    class Program{
        static void Main( string[] args){
            Application app = new Application ();
            app.Visible = false;
            app.OpenCurrentDatabase( @"c:\1\1.accdb");
            Console.WriteLine(app.CurrentDb().Properties.Count.ToString());
            Database db = app.CurrentDb();
            db.Close();
            Console.Read();
        }
    }
}

Open in new window

0

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
midfdeAuthor Commented:
I expected more gracefull solution, without unnecessary Application Object.
0
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
.NET Programming

From novice to tech pro — start learning today.