停止应用程序后删除Sqlite数据库记录

编程入门 行业动态 更新时间:2024-10-12 22:27:17
本文介绍了停止应用程序后删除Sqlite数据库记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

< add name = PITADatabaseConnectionString connectionString = 数据源= | DataDirectory | \ App_Data \ PITApplication.SQLite3Db;版本= 3; 的providerName = 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数据库记录

本文发布于:2023-11-27 10:50:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637769.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   数据库   Sqlite

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!