To make a connection to a data store, set the ConnectionString
property. Some common connection string
examples are:
Access
2003
@"Provider=Microsoft.Jet.OleDb.4.0;Data
Source=C:\Blog\Northwind.mdb";
Access
2010
@"Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Blog\Northwind.accdb";
"Data Source=MyServer;Initial
Catalog=Northwind;Integrate Security=True;";
Example
1 : Connecting to Sql Server 2012
Example
2 : Connecting to Access 2010
string connectionstring = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Blog\Northwind.accdb;";
OleDbConnection objConn = new OleDbConnection();
objConn.ConnectionString = connectionstring;
objConn.Open();
No comments:
Post a Comment