Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing windows base network application in c# .net and wants to know how to connect ms access database from network or form server pc.

Regards
Sujit Kesbhat
Posted

See discussion and sample code here OLE DB - First steps[^]
 
Share this answer
 
Comments
Member 9545493 8-Jan-13 4:57am    
i am not getting properly....
CHill60 8-Jan-13 5:10am    
Do you mean the link isn't working for you? In which case, search for OLE DB in the box in the top right hand corner of this page. If that's not what you meant, what are you not getting properly?
Member 9545493 9-Jan-13 1:47am    
Actually I am developing windows base network application means one application will use on network and I want to use ms access database from one server so now I have 5 pc in lan and one of them is server now I just want to know how to connect same database on each pc at a time mainly what type of connection string I can use for that
Hello

Not sure if you want a connection string or what...
But below this is how you connect to a MS Access Database

C#
string connString="Provider=Microsoft.Ace.OLEDB.12.0;DataSource=databasename.accdb";

       
        public DataTable getAuthentication()
        {

            using (OleDbConnection con = new OleDbConnection(connString))
            {
      OleDbCommand cmd = new OleDbCommand("SELECT * FROM tableName", con);


                DataTable dTable = new DataTable();
                OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
                adapter.SelectCommand = cmd;
                adapter.Fill(dTable);

                return dTable;
            }
        } 



Then you can use the method somewhere...
 
Share this answer
 
Comments
Member 9545493 9-Jan-13 1:47am    
Actually I am developing windows base network application means one application will use on network and I want to use ms access database from one server so now I have 5 pc in lan and one of them is server now I just want to know how to connect same database on each pc at a time mainly what type of connection string I can use for that
Anele Ngqandu 9-Jan-13 9:09am    
try
Data Source=|IP Address|\myDatabase.accdb;
User Id=admin;Password=****;
In response to your comment - connect as per Anele's solution above, just make sure that DataSource= contains the full server path name to your shared database

See also an example at http://www.connectionstrings.com/access-2007[^]

Things to be wary of ...If you are going to use a drive mapping for your network location (e.g. g:\myData\myDatabase.mdb) then you will need to make sure that everyone has the same drive mappings,
or use the DNS name (e.g. \\myServer\MyShare\myData\myDatabase.mdb)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900