Question

I have an application that I want to access a file over a network. I am currently using this connection string.

string myconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\" + PCName + "\\datafolder\\data.mdb";

The Pc name is the name of well the computer as seen on the network I get that using:

Dll Netapi32 however while i do get the path exactly as it should be my code adds "C:" to the path instead of "\PCNAME\datafolder\data.mdb" I have read a lot on this and none of it makes much sense because my code looks exactly as it should except i get that complication.

Was it helpful?

Solution

Your code line is looking pretty good. Try to add @ before the string or add back slash like this \\\\" + PCName

string myconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\\\" + PCName + "\\datafolder\\data.mdb";

If still it creates problem then assign that database shared folder as a Mapped Drive and use something like this. for example mapped drive is Z: (\\PCName\ApplicationFolder)

string myconnectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Z:\datafolder\data.mdb";

also this solution does not working then the problem may be in network pc permission.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top