[ Close ]
Username
Password


Forgotten your password?
 
Custom Search
Computer/IT Projects
 Projects Q A, Guidance for your projects Projects Forum Computer/IT Projects
Message Icon Topic: how to connect c#.net to ms access db? Post Reply Post New Topic
Found this useful? Give a +1   Add to Facebook: Add to Facebook
Free Project Downloads
CS / IT Project Downloads
.Net Project Downloads
JAVA Project Downloads
PHP Project Downloads
Networking Proj Downloads
Project Topics
Computer(CS/IT) Projects
Software Mini Project Topics
Android Project Topics
Networking Project Ideas
Dot Net Project Topics
Latest IEEE Projects List
IEEE JAVA Project Topics
Project Presentation Tips
How to choose Project Topic
Tips for Final Year Project
Steps for FYP, Mini Project
Preparing a Project Report
Problems faced in Projects
 
Get Free Software CS / IT Project Downloads:

Enter your email address:  

Author Message
abinayas09
Newbie
Newbie


Joined: 18-Apr-2013
Online Status: Offline
Posts: 0
Quote abinayas09 Replybullet Topic: how to connect c#.net to ms access db?
    Posted: 18-Apr-2013 at 4:41pm
how to connect c# to ms access db?

 
IP IP Logged
skumar
Senior Member
Senior Member


Joined: 19-Oct-2008
Location: United Kingdom
Online Status: Offline
Posts: 252
Quote skumar Replybullet Posted: 26-Jul-2013 at 1:44pm
If you want to connect to Access Database.

You have to follow the following steps:-

1) First add "using System.Data.OleDb;" at to top of the CS file.

2) Create connection string and open connection.
For access 2007
string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\abc.mdb;Jet OLEDB:Database Password=password";
OleDbConnection MyConn = new OleDbConnection(ConnStr);           

3) Open this connection.
MyConn.Open();

4) Create object for command and reader to get the data from access database.
OleDbCommand Cmd = new OleDbCommand(StrCmd, MyConn);;
OleDbDataReader ObjReader = Cmd.ExecuteReader();

5) Now lood through the reader object to get the data
if (ObjReader != null)
{

}

6) After completing the processing
ObjReader.Close();
MyConn.Close();

Thats all!

 
IP IP Logged
Viji
Newbie
Newbie


Joined: 09-Nov-2008
Online Status: Offline
Posts: 0
Quote Viji Replybullet Posted: 26-Jul-2013 at 1:46pm
The main thing that you need to know the ADO.NET
use system.data.oledb

This is the sample code for connecting with ACCESS

Code Block:

OleDbConnection con;   // create connection
OleDbCommand com; // create command
OleDbDataReader dr; //Dataread for read data from database
con = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\\mydb.mdb");
com = new OleDbCommand("Select * from Table1",con);
con.Open();                                        // open the coinnection
dr = com.ExecuteReader();

//now you can store into Gridview
GridView1.DataSource = dr;
GridView.DataBind();
con.Close(); //Close the connection

Simply you can use insertcommand with OledbCommand
IP IP Logged
Roopa
Newbie
Newbie


Joined: 09-Apr-2009
Online Status: Offline
Posts: 0
Quote Roopa Replybullet Posted: 26-Jul-2013 at 1:47pm
Refer this MSDN article on Creating Connections to Access Databases:

http://msdn.microsoft.com/en-us/library/5ybdbtte%28v=vs.71%29.aspx
IP IP Logged

 
Post Reply Post New Topic

Free Programming Courses in JAVA, .Net and PHP (Register Now!)

Java Free Online Course

.Net Free Online Course

PHP Free Online Course


 
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.
© ProjectsQA.com   |   Privacy policy