“数据源"不能为空.使用:memory:打开内存数据库“吝啬的? [英] What does "Data Source cannot be empty. Use :memory: to open an in-memory database" mean?

查看:54
本文介绍了“数据源"不能为空.使用:memory:打开内存数据库“吝啬的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的SQL Server数据库转换为SQLite DB.但是,当我尝试使用 .Open()打开我的SQLite时,会抛出此错误:

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

添加了连接字符串:

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

我为什么要得到这个?我将相同的SQL Server数据库转换为SQL CE和mySQL,但没有得到这些错误.

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

推荐答案

数据源后面有一个空格: Data Source = D:\ XXX.db .另外,在您的复制/粘贴中,连接字符串没有右引号.这是适用于我的测试工具的连接字符串:

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"

这篇关于“数据源"不能为空.使用:memory:打开内存数据库“吝啬的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆