停止应用程序后删除Sqlite数据库记录 [英] Sqlite database record deleted after stopping application

查看:71
本文介绍了停止应用程序后删除Sqlite数据库记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



在我使用sqlite数据库的C#windows应用程序中,我观察每次运行应用程序并将新记录插入数据库时​​,记录将只要应用程序仍在运行,就会保存,但是当我停止应用程序时,使用此连接字符串时将从数据库中删除(删除)记录:



 <   add     name   =  PITADatabaseConnectionString    connectionString   = 数据源= | DataDirectory | \ App_Data \ PITApplication.SQLite3Db;版本= 3;   的providerName  <跨度class =code-keyword> =  System.Data.Sqlite    /  >  





当我将连接字符串更改为:



 <   add     name   =  PITADatabaseConnectionString    connectionString   = 数据源= C:\SqLite \Gui \ SQLiteStudio \ PITApplication.SQLite3Db ;版本= 3;  

providerName = System.Data.Sqlite / >





并保存新记录,它将被永久保存而不会被删除。我不知道是什么问题,我通过添加新项目上下文菜单将数据库添加到我的应用程序中的文件夹,将数据库添加到我的应用程序后我设置了Build Action属性到内容,复制到输出目录属性总是复制。



i将非常感谢您的帮助。



我尝试过:



i使用了这个连接字符串:



< add name =PITADatabaseConnectionStringconnectionString =Data Source = | DataDirectory | \ App_Data \ PITApplication.SQLite3Db;版本= 3;providerName =System.Data.Sqlite/>

解决方案

我可以通过转到应用程序属性窗口,在设置下解决此问题我添加了一个连接字符串,指向app.config文件中的连接字符串。我还设置数据库的复制到输出目录属性,如果更新则复制,问题已解决,感谢所有贡献者。

Hello Everyone,

In my C# windows app using sqlite database, i observed each time i run the application and insert new records into the database, the records will be saved as long as the application is still running, but when i stopped the application, the records will be wiped out(deleted) from the database while using this connection string:

<add name="PITADatabaseConnectionString" connectionString="Data Source=|DataDirectory|\App_Data\PITApplication.SQLite3Db; Version=3;" providerName="System.Data.Sqlite" />



When i change the connection string to:

<add name="PITADatabaseConnectionString" connectionString="Data Source=C:\SqLite\Gui\SQLiteStudio\PITApplication.SQLite3Db; Version=3;"

      providerName="System.Data.Sqlite" />



and save new records, it will be saved permanently and not deleted. I don't know what the issue is, i added the database to a folder in my application through add new items context menu, after adding the database to my application i set Build Action property to Content, and Copy to output directory property to Copy always.

i will appreciate your kind assistance.

What I have tried:

i have used this connection string:

<add name="PITADatabaseConnectionString" connectionString="Data Source=|DataDirectory|\App_Data\PITApplication.SQLite3Db; Version=3;" providerName="System.Data.Sqlite" />

解决方案

I was able to resolve this issue by going to application properties window, under settings i added a connection string that points to the connection string in the app.config file. I also set the copy to output directory property of the database to copy if newer, and the issue was resolved, thanks to everyone that contributed.


这篇关于停止应用程序后删除Sqlite数据库记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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