增加null判断

croire 3 years ago
parent 19a11c6fe3
commit cb2a6055a4

@ -72,6 +72,8 @@ namespace DownKyi.Core.Storage.Database
/// </summary> /// </summary>
public void Open() public void Open()
{ {
if (conn == null) { return; }
if (!IsOpen()) if (!IsOpen())
{ {
conn.Open(); conn.Open();
@ -83,6 +85,8 @@ namespace DownKyi.Core.Storage.Database
/// </summary> /// </summary>
public void Close() public void Close()
{ {
if (conn == null) { return; }
if (IsOpen()) if (IsOpen())
{ {
conn.Close(); conn.Close();
@ -97,6 +101,8 @@ namespace DownKyi.Core.Storage.Database
/// <param name="sql"></param> /// <param name="sql"></param>
public void ExecuteNonQuery(string sql, Action<SQLiteParameterCollection> action = null) public void ExecuteNonQuery(string sql, Action<SQLiteParameterCollection> action = null)
{ {
if (conn == null) { return; }
try try
{ {
lock (conn) lock (conn)
@ -129,6 +135,8 @@ namespace DownKyi.Core.Storage.Database
/// <param name="action"></param> /// <param name="action"></param>
public void ExecuteQuery(string sql, Action<SQLiteDataReader> action) public void ExecuteQuery(string sql, Action<SQLiteDataReader> action)
{ {
if (conn == null) { return; }
try try
{ {
lock (conn) lock (conn)

Loading…
Cancel
Save