下面将创建内存数据库

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")

但是..如何创建临时数据库??documentationLink1Link2Link3Link4表示“要创建临时数据库,请使用空文件名”。但没人告诉确切的密码。
我试过各种组合
Dim cn As SQLiteConnection = New SQLiteConnection("")
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=")
Dim cn As SQLiteConnection = New SQLiteConnection("Data Source=C:\Temp\")

但都抛出异常/错误

最佳答案

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:")

关于database - 使用vb.net打开sqlite“临时”数据库的确切语法是什么,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35499901/

10-11 09:06
查看更多