访问 SQLite 文件时出错 [英] Error accesing SQLite file

查看:24
本文介绍了访问 SQLite 文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用过

http://sqliteadmin.orbmu2k.de/

创建我的 sqlite db 文件.我将它创建为 sqlite db 版本 3 文件.

to create my sqlite db file. I created it as a sqlite db version 3 file.

当我去打开连接

Dim Connection As New SQLite.SQLiteConnection(DATABASE_FILE_LOCATION)
Connection.Open()

我在 Open() 调用中遇到此异常

I am getting this exception on the Open() call

"打开的文件不是数据库文件文件已加密或不是数据库" (System.Data.SQLite.SQLiteException) 异常消息 = "打开的文件不是数据库文件\r\n文件已加密或不是数据库",异常类型 = "System.Data.SQLite.SQLiteException"

"File opened that is not a database file file is encrypted or is not a database" (System.Data.SQLite.SQLiteException) Exception Message = "File opened that is not a database file\r\nfile is encrypted or is not a database", Exception Type = "System.Data.SQLite.SQLiteException"

这里有什么问题?这是我的文件文件位置常量:

What is the issue here? Here is my file file location constant:

Private Const DATABASE_FILE_LOCATION As String = "Data Source=C:\Users\Scott\Desktop\Projects\Funds\Program\BudgetManager\Main.s3db;Version=3;"

推荐答案

您可以将此 c# 调整为 vb:

you could adapt this c# to vb:

private void showTables()
{
   SQLiteConnection cn = new SQLiteConnection("Data Source=myDatabase.db3");
   try
   {
        cn.Open();
        cn.SetPassword("MyPassword");
        DataTable tables = cn.GetSchema("Tables");
        Console.WriteLine("I have {0} tables", tables.Rows.Count);
        cn.Close();
   }
   catch (SQLiteException ex)
   {
       Console.WriteLine(ex.ToString());
   }
}

你的数据库有密码吗?您可以通过更改字符串告诉数据库您有密码:

Does your database have a password? You can tell database you have a password by changing the string:

SQLiteConnection cn = new 
SQLiteConnection("D:\Programming\Test\myDatabase.db3;Password=mypassword");

始终记得仔细检查是否已安装所有内容(http://sqlite.phxsoftware.com/)并且您对该数据库文件具有正确的权限.

Always remember to double check if everything is installed (http://sqlite.phxsoftware.com/) and you have right permissions on this database file.

如果您确定文件未加密,请重新安装 http://www.sqlite.org/cvstrac/wiki?p=ManagementTools

If you are sure file is not encrypted, reinstall http://www.sqlite.org/cvstrac/wiki?p=ManagementTools

这篇关于访问 SQLite 文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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