Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have 4 databases in a folder on my local drive, the problem starts when i move to a network drive on "\\192.168.1.62\Users\Public\ezidata\ezidata"
path1 ="\192.168.1.62\Users\Public\ezidata"
path ="\\192.168.1.62\Users\Public\ezidata\ezidata\font1.tmp"

my error is
System.Data.OleDb.OleDbException: ''C:\192.168.1.62\Users\Public\ezidata\font1.tmp' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.'


What I have tried:

var path1 = @"" + THEPath;
         var path = Path.Combine(path1, "font1.tmp");
          MessageBox.Show(path);
          OleDbConnection connect = new OleDbConnection
          {
              ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";" + " Jet OLEDB:Database Password=nif6914;"
          };

          connect.Open();
Posted
Updated 26-Jul-20 22:51pm

Look at the error message:
'C:\192.168.1.62\Users\Public\ezidata\font1.tmp' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

You cannot put an IP address after a local disk specifier:
C:\192.168.1.62\...


And you are probably letting yourself in for a world of pain later: most routers use dynamic IP allocation, so hard-coding local IP addresses (192.168.nnn.nnn is always a local IP address) is a bad idea. When the router is power cycled, or devices shut down, reboot, or power up in a different order the IP may not be the same.

Use local host names instead:
Data Source=\\MYCOMPUTER\share\folder\file.mdb
 
Share this answer
 
Well, if you dont want to create a share, but point to the C: drive, AND the privileges work out, you could use
\\192.168.1.62\c$\Users\Public\ezidata\ezidata
but that really exposes your C:\ drive

I'd make a share with the correct permissions, then maybe even map it with a dedicated/service user when your program starts, that way you control the access - have a look here and use this as the basis for mapping, then unmapping the drive Map Network Drive (API)[^]
 
Share this answer
 
v2
You would need to try something of form:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\serverName\shareName\folder\myAccessFile.mdb;

Refernece: Microsoft ACE OLEDB 12.0 Connection Strings - ConnectionStrings.com[^]
 
Share this answer
 
Thank u all
i have corrected my code to
var path1 = @"" + THEPath;
string path= path1+ "font1.tmp";
 
Share this answer
 
Comments
Dave Kreskowiak 27-Jul-20 10:31am    
What the hell is this:
 @"" + THEPath;

You DO NOT need the @"" garbage.

All you did was this:
var path1 = THEPath;

And that does NOTHING in your code.

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