What does “Data Source cannot be empty. Use :memory: to open an in-memory database” mean?

ⅰ亾dé卋堺 提交于 2019-12-01 14:12:27

问题


I recently converted my SQL Server database into SQLite DB. But when I try to open my SQLite using .Open() it throws me this error:

Data Source cannot be empty.  Use :memory: to open an in-memory database

Edit: added connection string:

ConnectionString = @"Data Source=D:\XXX.db;Version=3";
connection = new SQLiteConnection(connectionString);
connection.Open();

Why do I get this? I converted the same SQL Server database to SQL CE and mySQL and I didn't get these errors.


回答1:


There's a space after your data source: Data Source= D:\XXX.db. Also, in your copy/paste, there's no closing quote to the connection string. Here's a connection string that works for me for the testing tool:

@"Data Source=C:\Temp\Test.db3;Pooling=true;FailIfMissing=false;Version=3"



回答2:


Because your Data Source is empty. Add the Data Source paramater to your connection string. before opening the Sqlite database.




回答3:


You haven't provided a data source name, aka where the sqlite file exists.



来源:https://stackoverflow.com/questions/4039720/what-does-data-source-cannot-be-empty-use-memory-to-open-an-in-memory-databa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!