C# System.Data.OleDb.OLEDBEException未处理:不是有效路径

C# System.Data.OleDb.OLEDBEException未处理:不是有效路径,c#,winforms,visual-studio-2010,ms-access,C#,Winforms,Visual Studio 2010,Ms Access,这是我第一次尝试从服务器访问db文件。如果在本地运行该程序,则不会出现问题 我将ms access文件存储在服务器上,试图从笔记本电脑运行该程序,但收到以下错误 System.Data.OleDb.OleDbException was unhandled is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which

这是我第一次尝试从服务器访问db文件。如果在本地运行该程序,则不会出现问题

我将ms access文件存储在服务器上,试图从笔记本电脑运行该程序,但收到以下错误

System.Data.OleDb.OleDbException was unhandled 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.
我的连接字符串看起来像这样

myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\name-SERVER\SHAREDFILES\FileRDB.mdb; Jet OLEDB:System Database=system.mdw");
System.Data.OleDb.OleDbException was unhandled
   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.
  Source=Microsoft JET Database Engine
  ErrorCode=-2147467259
  StackTrace:
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at MALHRManagementSystem.FrmLogin.btnLogin_Click(Object sender, EventArgs e) in C:\Users\username\Desktop\Project\foldername\foldername\foldername\Form.cs:line 40
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at somefilename.Program.Main() in C:\Users\username\Desktop\Project\foldername\foldername\foldername\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
有服务器的用户名和密码。我应该将其包含在连接字符串中吗

Stacktrace看起来像这样

myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\name-SERVER\SHAREDFILES\FileRDB.mdb; Jet OLEDB:System Database=system.mdw");
System.Data.OleDb.OleDbException was unhandled
   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.
  Source=Microsoft JET Database Engine
  ErrorCode=-2147467259
  StackTrace:
       at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
       at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.OleDb.OleDbConnection.Open()
       at MALHRManagementSystem.FrmLogin.btnLogin_Click(Object sender, EventArgs e) in C:\Users\username\Desktop\Project\foldername\foldername\foldername\Form.cs:line 40
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at somefilename.Program.Main() in C:\Users\username\Desktop\Project\foldername\foldername\foldername\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
请有人告诉我如何纠正这个问题

提前谢谢

我不知道我应该用什么标签,但请纠正它,如果我在这里错了


db是MS Access 2003和visual studio 2010,现在正在运行。在vista/Windows 7上使用映射网络驱动器。右键单击我的电脑>映射网络驱动器>选择驱动器>单击浏览按钮。一个菜单显示为“浏览文件夹--选择共享网络文件夹”。然后选择网络名称和文件夹。完成此操作后,单击“确定”。这就是你所要做的。如果有人感兴趣,这里有一些关于如何做的有用链接


如果您将文件路径放在文件资源管理器中,它会指向您的数据库吗?I您不确定连接字符串是如何构造的。使用的是
H:
驱动器网络驱动器吗?该驱动器映射依赖于用户,所以如果您的应用程序现在以其他用户的身份运行,则该映射将丢失。改为使用UNC路径(\\server\folder)。我在文件资源管理器中没有想到文件路径。明天我会试试,因为我不在那里。我知道的连接字符串网站。我只是想知道在网络方面是否需要做些什么?@HansKesting-我不知道H:是不是网络驱动器?我不知道UNC路径(\\server\folder)。是可能的,你可以解释这项工作,建议一个网站等。谢谢