string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\data\sample.accdb"; using (OleDbConnection connection = new OleDbConnection(connectionString)) { // Open the connection connection.Open(); // Perform database operations }
using (OleDbCommand command = new OleDbCommand()) { command.Connection = connection; command.CommandText = "INSERT INTO Customers (FirstName, LastName) VALUES (@FirstName, @LastName)"; command.Parameters.AddWithValue("@FirstName", "John"); command.Parameters.AddWithValue("@LastName", "Doe"); command.ExecuteNonQuery(); }Package library: System.Data.OleDb is part of the .NET Framework Class Library.