Thomas Sampson

C# Microsoft Access database access

Leave a comment

This can be used in either a windows application OR an file.

NOTICE: if using with file the access file MUST be placed and refered to in the ROOT directory of IIS.

ok, first make the reference

using System.Data.OleDb;

to open and close connection….

OleDbConnection thisConnection = new OleDbConnection(
@”Provider=Microsoft.Jet.OLEDB.4.0;” +
@”Data Source=E:/WEB_SERVER/server_user_database.MDB”);
//work here//

to add data…

OleDbCommand new1 = new OleDbCommand(“INSERT INTO tablename (column(s)) values(‘valueshere’)”, thisConnection);

to retrieve data…

OleDbDataReader myReader=null;
OleDbCommand test = new OleDbCommand(“select * from tablename, thisConnection);
myReader = test.ExecuteReader();

always close connection!!!…



Author: tomtech999

I have recently graduated with a 1st class degree in MComp Games Software Development at Sheffield Hallam University, focusing primarily on application development in C++, with experience in graphics programming, scripting languages, DVCS/VCS and web technology. In my spare time I enjoy Drumming, Reading and Snowboarding!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s