Answered by:
C# connection string

Question
-
Hi all,
on server I have a *mdb file (database) ... how can I connect to this file and use it? Thank you.
Tuesday, September 16, 2014 9:09 AM
Answers
-
You need to include the drive letter like c:\. That is why I suggested using a windows explorer before you just attempt to modify the code.
jdweng
- Proposed as answer by Amanda Zhu Wednesday, September 17, 2014 6:17 AM
- Marked as answer by Amanda Zhu Wednesday, September 24, 2014 1:48 AM
Tuesday, September 16, 2014 12:05 PM
All replies
-
This is a Microsoft Access Database format
Take a peek on connection strings at:
http://www.connectionstrings.com/access/
- Edited by cnk_gr Tuesday, September 16, 2014 9:18 AM
Tuesday, September 16, 2014 9:17 AM -
You need the -proper credentials to directly connect to the mdb file. You can use the full path including the server name like //servername/c:/...... See the connection string webpage for more details
http://www.connectionstrings.com/access/
jdweng
Tuesday, September 16, 2014 9:20 AM -
I tried it .. but it doesnt work for me and I really dont know what I am doing wrong. Do you have any example?
so .. I tried this:
OleDbConnection con = new OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;Data Source=\\***.*.*.**,80"); try { con.Open(); MessageBox.Show("Connected"); } catch(Exception e) { MessageBox.Show(e.Message); Application.Current.Shutdown(); }
but ..... before I posted this question I tried this and it semmsed to be connected but I dont know how to read file from it ...
try { TcpClient tcpclnt = new TcpClient(); tcpclnt.Connect("***.***.*.**", 80); MessageBox.Show("Connected"); } catch (Exception e) { MessageBox.Show(e.Message); }
Tuesday, September 16, 2014 11:06 AM -
You may not need to use TCP. Open a windows explorer and see if you can locate the file using a URL like //servername/c:/....... If you can then the simply enter the the pathname where the file is located. You are trying to use Port 80 in your connection string and this will only work if you have a service running on the remote PC. It iwill be easier if you just have the full pathname of the location of the mdb including the server name.
jdweng
Tuesday, September 16, 2014 11:15 AM -
With the provider you attach to the DB file on a local share or your filesystem, not over the internet.
Just download the mdb file and attach it locally.
Tuesday, September 16, 2014 11:51 AM -
OK, so I tried this ..
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\19*.***.*.**/folder/public/database.mdb"); try { con.Open(); MessageBox.Show("Connected"); con.Close(); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); Application.Current.Shutdown(); }
It show me a message> Error:\\19*.***.*.**/folder/public/database.mdb is not correct path
so ... what now
Tuesday, September 16, 2014 11:55 AM -
You should try:
\\19.*.*.*\folder\public\database.mdb
or create a map drive to
Make sure you have rights to the path.
Tuesday, September 16, 2014 11:58 AM -
You need to include the drive letter like c:\. That is why I suggested using a windows explorer before you just attempt to modify the code.
jdweng
- Proposed as answer by Amanda Zhu Wednesday, September 17, 2014 6:17 AM
- Marked as answer by Amanda Zhu Wednesday, September 24, 2014 1:48 AM
Tuesday, September 16, 2014 12:05 PM -
Thank you all, problem solved :-)Tuesday, September 16, 2014 12:32 PM
-
Hi TakeshiKitano,
Glad to see this issue is resolved. Whether Joel Enginerr helped you resolve this issue? If yes, you can mark his reply as answer.
If you resolved it yourself, could you please post the solution here?It will help many persons who are experiencing such issue.
Thanks,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Wednesday, September 17, 2014 6:17 AM