你好我有一个插入查询,但问题是它锁定数据库它是唯一的数据库连接但它保持锁定是否有人知道如何修复它这是我运行的唯一脚本,它应该工作
using UnityEngine;
using System.Collections;
using Parse;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Mono.Data.Sqlite;
using System.Data;
public class ParseInputId : MonoBehaviour {
void Start()
{
string conn = "";
string Question;
//string sqlQuery;
#if UNITY_EDITOR
conn = "URI=file:" + Application.persistentDataPath + "/" + "App.db";
Debug.Log (conn);
#elif UNITY_IPHONE
conn = "URI=file:" + Application.persistentDataPath + "/" + "App.db";
#elif UNITY_ANDROID
conn = "URI=file:" + Application.persistentDataPath + "/" + App.db";
#endif
//string conn = "URI=file:" + Application.dataPath + "/App.db"; //Path to database.
string toreplace;
IDbConnection dbconn;
dbconn = (IDbConnection) new SqliteConnection(conn);
dbconn.Open(); //Open connection to the database.
IEnumerable<ParseObject> results = t.Result;
IDbCommand dbcmd = dbconn.CreateCommand();
string sqlQuery = "INSERT INTO TEST (Field1) Values (1)";
Debug.Log (sqlQuery);
dbcmd.CommandText = sqlQuery;
IDataReader reader = dbcmd.ExecuteReader();
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbconn.Close();
dbconn = null;
}
}
我已尝试过所有操作,甚至重新启动计算机并尝试其他项目。
如果有人能尽快回复我,那将非常感谢大家的光临
答案 0 :(得分:2)
在USING语句中包裹您的连接,以便在完成后将其妥善处理:
using (dbconn SqliteConnection = new (IDbConnection)SqliteConnection(conn)) {
// Put the rest of your code here.
}