如何使用C#Winrt应用程序在SQLite中插入记录 [英] How to insert a record in SQLite by using C# Winrt app
问题描述
你好
我是SQLite的新手.我正在尝试从winrt应用程序插入一条记录,但出现异常无法打开".我已经设置了所有权限,但仍然面临异常.我的代码如下
I am new with SQLite. I am trying to insert a record from winrt app but got an exception "Can not open". I already set all permissions but still facing exception. My code is as below
公共异步void insertQuery()
{
尝试
{
使用(var db = new SQLite.SQLiteConnection(dbPath,SQLiteOpenFlags.ReadWrite,true))
{
SQLiteCommand cmd =新的SQLiteCommand(db);
cmd.CommandText =插入PERSON(FIRSTNAME,LASTNAME)值('ABDULLAH','FAISAL')''';
cmd.ExecuteNonQuery();
}
}
捕获(异常除外)
{
}
}
public async void insertQuery()
{
try
{
using (var db = new SQLite.SQLiteConnection(dbPath, SQLiteOpenFlags.ReadWrite, true))
{
SQLiteCommand cmd = new SQLiteCommand(db);
cmd.CommandText = "insert into PERSON (FIRSTNAME,LASTNAME) values ('ABDULLAH','FAISAL')";
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
}
}
谢谢
推荐答案
数据库文件是否是只读文件?数据库在哪里?是在Windows.Storage.ApplicationData.Current.LocalFolder.Path下吗?
Is the database file read-only by any chance? Where is the database located? Is it under Windows.Storage.ApplicationData.Current.LocalFolder.Path?
这篇关于如何使用C#Winrt应用程序在SQLite中插入记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!