使用 vb.net 打开 sqlite "Temporary" 数据库的确切语法是什么
what is the exact sytax to open sqlite "Temporary" database using vb.net
下面会在内存中创建db
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=:memory:")
下面将在 C:\Temp\
中创建名称为 abc 的磁盘文件 db
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=C:\Temp\abc")
或
下面将在默认位置创建名称为 abc 的磁盘文件 db ..\SqliteProject\bin\Debug
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=abc")
但是..如何创建临时数据库?? documentation Link1 Link3 Link4 说 "to create temporary db use empty filename"。但没有人告诉确切的代码。
我尝试了各种组合
Dim cn As SQLiteConnection = New SQLiteConnection("")
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=")
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=C:\Temp\")
但全部抛出 exception/error
System.Data.SQLite 使用以下代码检查数据库名称:
fileName = FindKey(opts, "Data Source", DefaultDataSource);
if (String.IsNullOrEmpty(fileName))
{
fileName = FindKey(opts, "Uri", DefaultUri);
if (String.IsNullOrEmpty(fileName))
{
fileName = FindKey(opts, "FullUri", DefaultFullUri);
if (String.IsNullOrEmpty(fileName))
throw new ArgumentException(UnsafeNativeMethods.StringFormat(CultureInfo.CurrentCulture, "Data Source cannot be empty. Use {0} to open an in-memory database", MemoryFileName));
因此无法指定空名称。
但是,可以使用空路径指定 URI 文件名:
New SQLiteConnection("FullUri=file:")
下面会在内存中创建db
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=:memory:")
下面将在 C:\Temp\
中创建名称为 abc 的磁盘文件 dbDim cn As SQLiteConnection = New SQLiteConnection("Data Source=C:\Temp\abc")
或 下面将在默认位置创建名称为 abc 的磁盘文件 db ..\SqliteProject\bin\Debug
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=abc")
但是..如何创建临时数据库?? documentation Link1
Dim cn As SQLiteConnection = New SQLiteConnection("")
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=")
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=C:\Temp\")
但全部抛出 exception/error
System.Data.SQLite 使用以下代码检查数据库名称:
fileName = FindKey(opts, "Data Source", DefaultDataSource);
if (String.IsNullOrEmpty(fileName))
{
fileName = FindKey(opts, "Uri", DefaultUri);
if (String.IsNullOrEmpty(fileName))
{
fileName = FindKey(opts, "FullUri", DefaultFullUri);
if (String.IsNullOrEmpty(fileName))
throw new ArgumentException(UnsafeNativeMethods.StringFormat(CultureInfo.CurrentCulture, "Data Source cannot be empty. Use {0} to open an in-memory database", MemoryFileName));
因此无法指定空名称。
但是,可以使用空路径指定 URI 文件名:
New SQLiteConnection("FullUri=file:")