I have two PCs P1 and P2. My Access database db is in F2 folder in P2. F2 is shared and I can see it in P1 due to same workgroup name. My C# app is running in P1. I use mode share deny none in connectionstring and can access db without any issue. But whenever I restart P2, I have to provide login info of P2 window user usr/pwd in P1 by clicking on \P2\F2 by going to network places and workgroup computers, etc., otherwise I get permission denied in C# while accessing db. My question is: Is there any way that I just switch ON P2 (not loging into OS) and can access db from P1 without double clicking on F2 in P1 and providing usr/pwd. Can I provide use/pwd of P2 window user in connectionstring of C# app in P1. Please guide. Thanks regards, Saf
Asked
Active
Viewed 40 times
-1
-
Have you tried adding P2/F2 permanently as a network share in windows? This isn't something that your program should have to take care of. You might want to use an SQL-Server instead, Access is kind of outdated and a shared Access Database isn't the best idea to begin with. – Manfred Radlwimmer Mar 27 '18 at 12:17
-
2Welcome to Stackoverflow. Please read a [guide that helps to ask a good question](https://stackoverflow.com/help/how-to-ask). – Fabjan Mar 27 '18 at 12:19
-
1The solution would probably be to use an actual database server, not whatever Access is. – nvoigt Mar 27 '18 at 12:25
-
In fact my PC P2 is too old to run SQL server. Sorry. I have to use Access, but I want to get rid of logging into P2 from P1each time when I run C# app from P1...any good idea other than SQL Server? – Safdar Zaman Mar 28 '18 at 10:17
1 Answers
-1
Create a user in PC1 and PC2 with same username and password and run the application below this user. This way the windows ntlm authentication will automatically authenticate you at the remote server (windows normally always tries to authenticate with the current principle at the remote server).
If this is no option, you would need to check if you are authenticated with File.Exists
and if not authenticate at the remote share.
You can find information about authenticating in following so post. With the class in the post from Luke Quinane you can then simply do:
new NetworkConnection(@"\\server\read", readCredentials)
Access itself does not have authentication due to this happening by file system/operating system. And Access is only file based.

dsdel
- 1,042
- 1
- 8
- 11