// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data; using System.Data.OleDb; namespace E { public abstract class DB { private string constr; protected abstract string DBFile { get; } public DB() { constr = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};User Id=admin;Password=;", DBFile); } public void DoSomething() { using(OleDbConnection con = new OleDbConnection(constr)) { con.Open(); // ... } } } public class DBX : DB { protected override string DBFile { get { return @"C:\Work\Database11.accdb"; } } public void DoMore() { DoSomething(); // ... } } public class Program { public static void Main(string[] args) { DBX o = new DBX(); o.DoMore(); } } }