Esempio n. 1
0
 /// <summary>
 /// 增、删、改(SQLite)
 /// </summary>
 /// <param name="dbPath"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public int SQLiteExecute(string dbPath, SQLIteDbParameter param)
 {
     using (SQLiteConnection conn = new SQLiteConnection($"data source={dbPath}"))
     {
         conn.Open();
         using (SQLiteCommand cmd = new SQLiteCommand(conn))
         {
             cmd.CommandType = System.Data.CommandType.Text;
             cmd.CommandText = param.SqlCmdTxt;
             foreach (var item in param.SqlLiteParameters)
             {
                 cmd.Parameters.Add(item);
             }
             return(cmd.ExecuteNonQuery());
         }
     }
 }
Esempio n. 2
0
 public DataSet SQLiteGetDataSet(string dbPath, SQLIteDbParameter param)
 {
     using (SQLiteConnection conn = new SQLiteConnection($"data source={dbPath}"))
     {
         conn.Open();
         DataSet dt = new DataSet();
         using (SQLiteDataAdapter da = new SQLiteDataAdapter())
         {
             using (SQLiteCommand cmd = new SQLiteCommand())
             {
                 cmd.CommandType = System.Data.CommandType.Text;
                 cmd.CommandText = param.SqlCmdTxt;
                 foreach (var item in param.SqlLiteParameters)
                 {
                     cmd.Parameters.Add(item);
                 }
                 da.SelectCommand = cmd;
             }
             da.Fill(dt);
             return(dt);
         }
     }
 }