C# sqlite执行sql

C# sqlite执行sql

 

/// <summary>
/// 执行增删改查操作
/// </summary>
/// <param name="sql">查询语言</param>
/// <returns></returns>
public static int ExecuteNonQuery(string db, string sql)
{
    try
    {
        SQLiteCommand cmd;
        cmd = new SQLiteCommand(sql, dbConnection(db));
        cmd.ExecuteNonQuery().ToString();
        return 1;
    }
    catch (Exception ex)
    {
        Console.WriteLine("ExecuteNonQuery(" + sql + ")Err:" + ex.Message);
        return 0;
    }
    finally
    {
        closeConn();
    }
}

 

 

 

###########################

posted @ 2021-11-18 07:32  西北逍遥  阅读(288)  评论(0编辑  收藏  举报