将SQLite与Windows应用程序集成 [英] Integrating SQLite with a Windows application

查看:89
本文介绍了将SQLite与Windows应用程序集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我创建了一个简单的WPF应用程序,该应用程序允许用户将字符串插入到SQLite数据库(.S3DB文件)中.用户还可以从数据库中选择一个字符串,然后从数据库中删除该字符串...非常简单的应用程序.

So I created a simple WPF application that allows a user to INSERT a string into a SQLite database (a .S3DB file). The user can also SELECT a string from the database and DELETE the string from the database...very simple application.

我想分发这个简单的应用程序,因此我已经通过创建一个新项目并使用VS2010上的安装向导为该应用程序创建了setup.exe文件.当用户安装该应用程序时,它将在Program Files目录中创建一个"TestDatabase"文件夹,并将这两个文件与.exe文件一起添加:

I want to distribute this simple application, so I've created setup.exe file for the application by creating a new project and using the setup wizard on VS2010. When the user installs the application, it creates a "TestDatabase" folder in the Program Files directory and adds these two files along with the .exe file:

  1. System.Data.SQLite.DLL文件(因为它是检测到的依赖项)
  2. TestDatabase.s3db文件(供用户使用的测试数据库)

当我将其安装在计算机上时,我正在开发...一切正常.但是,当我将其安装在另一台计算机上时,当我尝试从应用程序(存储在C:\ Program Files(x86)\ TestDatabase \ TestDatabase.s3db中)打开数据库时,它会崩溃.

When I install it on the computer I'm developing on...everything works. However, when I install it on another computer, it crashes when I try to open the database from the application (which is stored in C:\Program Files (x86)\TestDatabase\TestDatabase.s3db).

我想知道是否有人可以帮助解决这个问题?谢谢.

I was wondering if someone can help solve this problem? Thanks.

推荐答案

我意识到打开数据库时崩溃的原因是我没有在要测试的新计算机上安装安装程序包.安装程序包包括所有运行时组件和依赖项.可以在这里找到安装程序包:

I realized that the reason why it was crashing when I opened the database is because I didn't install the setup package on the new computer I was testing on. The setup package includes all the runtime components and dependencies. The setup packages can be found here:

http://system.data.sqlite. org/index.html/doc/trunk/www/downloads.wiki

另外,ravenspoint,RandomEngy和bryanbcook ...你们是正确的.从Program Files文件夹读取/写入数据库是一个坏主意,因为从Program Files文件夹访问数据库时可能会发生权限问题.因此,我将数据库保存在AppData文件夹中,可以在其中读取/写入数据库而没有任何权限问题.

Also, ravenspoint, RandomEngy, and bryanbcook...you guys were right. Reading/writing a database from the Program Files folder is a bad idea because of the permission problem that can occur when accessing the database from the Program Files folder. So I saved my database in the AppData folder where the database can be read/written without any permission problems.

这篇关于将SQLite与Windows应用程序集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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