Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在其他计算机中使用路径_Sql_Database_Winforms_Sqlite - Fatal编程技术网

Sql 在其他计算机中使用路径

Sql 在其他计算机中使用路径,sql,database,winforms,sqlite,Sql,Database,Winforms,Sqlite,如何在不更改路径的情况下将数据库与另一台计算机一起使用 我正在使用这条路径 SQLiteConnection conn = new SQLiteConnection( "data source=C:\\Users\\users\\Documents\\Visual Studio 2012\\Projects\\SKM Computerized Payroll System\\db_SKMPayroll.sqlite"); 不要使用当前用于数据库文件的路径。它是用于存储开发中的VS项目的位置。部

如何在不更改路径的情况下将数据库与另一台计算机一起使用

我正在使用这条路径

SQLiteConnection conn = new SQLiteConnection(
"data source=C:\\Users\\users\\Documents\\Visual Studio 2012\\Projects\\SKM Computerized Payroll System\\db_SKMPayroll.sqlite");

不要使用当前用于数据库文件的路径。它是用于存储开发中的VS项目的位置。部署应用程序时,不应使用任何开发文件夹

您应该为数据库使用专用文件夹,如
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

或者您可以,前提是每个用户都有读/写权限(例如,它不应该在
程序文件中)

试试这个:

SQLiteConnection conn = new SQLiteConnection(
 string.Format(
   "data source={0}", 
   Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "db_SKMPayroll.sqlite"))

如果您使用存储在
\bin\Debug
\bin\Release
文件夹中的数据库文件,请确保在另一台计算机上存在相同的路径,以确保
\bin\
文件夹中的开发数据库与项目中的数据库文件一起被重写。

。您试图解决的实际问题是什么?当我的程序在exe文件中时,它不会读取其他计算机上的程序,除非我更改该计算机上的路径了解如何使用
=@“data source=C:\Users\Users\…