当前位置: 首页>>代码示例>>C#>>正文


C# SQLite.SQLiteDataAdapter类代码示例

本文整理汇总了C#中System.Data.SQLite.SQLiteDataAdapter的典型用法代码示例。如果您正苦于以下问题:C# SQLiteDataAdapter类的具体用法?C# SQLiteDataAdapter怎么用?C# SQLiteDataAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SQLiteDataAdapter类属于System.Data.SQLite命名空间,在下文中一共展示了SQLiteDataAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteReader

        public static DataTable ExecuteReader(string sqlitefn, string command, List<SqliteParam> parameters, out string errorMessage)
        {
            DataTable dt = null;
            try
            {
                errorMessage = "";
                using (var conn = new SQLiteConnection(sqlitefn))
                {
                    conn.Open();
                    var commandSql = new SQLiteCommand(command, conn);
                    if (parameters != null && parameters.Count > 0)
                    {
                        foreach (SqliteParam param in parameters)
                        {
                            commandSql.Parameters.Add(param.Name, param.Type).Value = param.Value;
                        }

                    }
                    dt = new DataTable();
                    var sqlDa = new SQLiteDataAdapter(commandSql);
                    sqlDa.Fill(dt);
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.ToString();
                dt = null;
            }
            return dt;
        }
开发者ID:dzolou2011,项目名称:InteractiveCoffee,代码行数:31,代码来源:SqlHelper.cs

示例2: ExecuteNonQueryDt

        public static DataTable ExecuteNonQueryDt(string cmdText, SQLiteConnection con)
        {
            DataTable dt = new DataTable("Table");
            try
            {

                using (con)
                {
                    SQLiteDataAdapter da = new SQLiteDataAdapter(cmdText, con);
                    con.Open();
                    da.Fill(dt);
                    con.Close();
                }
                return dt;
            }
            catch (Exception ex)
            {
                using (FileStream file = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\" + System.DateTime.Now.Date.ToString("dd-MMM-yyyy") + "_Log.txt", FileMode.Append, FileAccess.Write))
                {
                    StreamWriter streamWriter = new StreamWriter(file);
                    streamWriter.WriteLine(System.DateTime.Now + " - " + "ExecuteNonQueryDt" + " - " + ex.Message.ToString());
                    streamWriter.Close();
                }
                return dt;
            }
        }
开发者ID:Prasadambulkar3,项目名称:msgBlaster-api,代码行数:26,代码来源:ReadSqliteData.cs

示例3: Update

 private bool Update(int orderID, string pymntID, string state, string amount, string description, string updatedAt)
 {
     bool isSuccess = false;
     int rowsAffacted = 0;
     StringBuilder sqliteQueryUpdate = new StringBuilder();
     sqliteQueryUpdate.Append("UPDATE orders ");
     sqliteQueryUpdate.Append("SET ");
     sqliteQueryUpdate.Append("payment_id = @payment_id, ");
     sqliteQueryUpdate.Append("state = @state, ");
     sqliteQueryUpdate.Append("amount = @amount, ");
     sqliteQueryUpdate.Append("description = @description, ");
     sqliteQueryUpdate.Append("updated_at = @updated_at ");
     sqliteQueryUpdate.Append("WHERE ");
     sqliteQueryUpdate.Append("id = @id");
     SQLiteDataAdapter sqliteDataAdapterUpdate = new SQLiteDataAdapter();
     sqliteDataAdapterUpdate.UpdateCommand = new SQLiteCommand();
     sqliteDataAdapterUpdate.UpdateCommand.Parameters.AddWithValue("@payment_id", pymntID);
     sqliteDataAdapterUpdate.UpdateCommand.Parameters.AddWithValue("@state", state);
     sqliteDataAdapterUpdate.UpdateCommand.Parameters.AddWithValue("@amount", amount);
     sqliteDataAdapterUpdate.UpdateCommand.Parameters.AddWithValue("@description", description);
     sqliteDataAdapterUpdate.UpdateCommand.Parameters.AddWithValue("@updated_at", updatedAt);
     sqliteDataAdapterUpdate.UpdateCommand.Parameters.AddWithValue("@id", orderID);
     dataAccessObject = new DataAccessLayer();
     rowsAffacted = dataAccessObject.Update(sqliteQueryUpdate.ToString(), sqliteDataAdapterUpdate);
     if (rowsAffacted > 0)
     {
         isSuccess = true;
     }
     return isSuccess;
 }
开发者ID:DanieJoe,项目名称:rest-api-sample-app-dotnet,代码行数:30,代码来源:PlaceOrdersController.cs

示例4: ExecuteDataSet

        public static DataSet ExecuteDataSet(string SqlRequest, SQLiteConnection Connection)
        {
            DataSet dataSet = new DataSet();
            dataSet.Reset();

            SQLiteCommand cmd = new SQLiteCommand(SqlRequest, Connection);
            try
            {
                Connection.Open();
                SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(cmd);
                dataAdapter.Fill(dataSet);
            }
            catch (SQLiteException ex)
            {
                Log.Write(ex);
                //Debug.WriteLine(ex.Message);
                throw; // пересылаем исключение на более высокий уровень
            }
            finally
            {
                Connection.Dispose();
            }

            return dataSet;
        }
开发者ID:alexrigin,项目名称:HMS2,代码行数:25,代码来源:DBManager.cs

示例5: loadHeroDiary

        private void loadHeroDiary()
        {
            // Load the latest Hero Diary entries
            using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=" + dbPath + @"\gv.db;Version=3;New=False;Compress=True;"))
            {
                conn.Open();
                using (SQLiteCommand cmd = conn.CreateCommand())
                {
                    string commandText = "select Diary_ID as ID, Updated, EntryTime, Entry from Diary where [email protected] order by Diary_ID desc limit 1000";
                    cmd.CommandText = commandText;
                    cmd.Parameters.AddWithValue("@HeroName", this.HeroName);

                    SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    da = new SQLiteDataAdapter(cmd);
                    ds = new DataSet();
                    da.Fill(ds);

                    BindingSource bindingSource = new BindingSource();
                    bindingSource.DataSource = ds.Tables[0];
                    grdDiary.DataSource = bindingSource;
                    grdDiary.AutoGenerateColumns = true;
                    grdDiary.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
                    grdDiary.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                }
            }
        }
开发者ID:DougThompson,项目名称:GodvilleAutoPlayer,代码行数:27,代码来源:frmDiary.cs

示例6: FetchAll

 /// <summary>
 /// Получить данные из таблицы
 /// </summary>
 /// <param name="databasename">Имя таблицы</param>
 /// <param name="where">Условия</param>
 /// <param name="etc">Остальные параметры: сортировка, группировка и т.д.</param>
 /// <returns>Таблица с данными</returns>
 public DataTable FetchAll(string databasename, string where, string etc)
 {
     DataTable dt = new DataTable();
     string sql = string.Format("SELECT * FROM {0} {1} {2}", databasename, where, etc);
     ConnectionState previousConnectionState = ConnectionState.Closed;
     using (SQLiteConnection connect = new SQLiteConnection(ConnectionString))
     {
         try
         {
             previousConnectionState = connect.State;
             if (connect.State == ConnectionState.Closed)
             {
                 connect.Open();
             }
             SQLiteCommand command = new SQLiteCommand(sql, connect);
             SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
             adapter.Fill(dt);
         }
         catch (Exception error)
         {
             System.Windows.Forms.MessageBox.Show(error.Message, "Ошибка при получении данных из базы", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return null;
         }
         finally
         {
             if (previousConnectionState == ConnectionState.Closed)
             {
                 connect.Close();
             }
         }
     }
     return dt;
 }
开发者ID:tatar1nro,项目名称:KKM_PFR_ScanTerminal,代码行数:40,代码来源:dbFacade.cs

示例7: ExecuteDataSet

 /// <summary>
 /// 执行数据库查询,返回DataSet对象
 /// </summary>
 /// <param name="connectionString">连接字符串</param>
 /// <param name="commandText">执行语句或存储过程名</param>
 /// <param name="commandType">执行类型</param>
 /// <returns>DataSet对象</returns>
 public DataSet ExecuteDataSet(string connectionString, string commandText, CommandType commandType)
 {
     if (connectionString == null || connectionString.Length == 0)
         throw new ArgumentNullException("connectionString");
     if (commandText == null || commandText.Length == 0)
         throw new ArgumentNullException("commandText");
     DataSet ds = new DataSet();
     SQLiteConnection con = new SQLiteConnection(connectionString);
     SQLiteCommand cmd = new SQLiteCommand();
     SQLiteTransaction trans = null;
     PrepareCommand(cmd, con, ref trans, false, commandType, commandText);
     try
     {
         SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
         sda.Fill(ds);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (con != null)
         {
             if (con.State == ConnectionState.Open)
             {
                 con.Close();
             }
         }
     }
     return ds;
 }
开发者ID:GininDev,项目名称:ServicesInforCollector,代码行数:39,代码来源:SQLiteHelper.cs

示例8: pegaExcecoesBloqueio

        public static DataTable pegaExcecoesBloqueio(string termo)
        {
            string sql = "SELECT * FROM excecoes INNER JOIN bloqueios ON blo_id = exc_bloqueio WHERE blo_termo = @termo";
            SQLiteConnection con = conexao.conectar();
            SQLiteCommand cmd = new SQLiteCommand(sql, con);
            cmd.Parameters.Add(new SQLiteParameter("@termo",termo));
            DataTable dados = null;

            try
            {
                cmd.ExecuteNonQuery();
                SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                dados = new DataTable();
                da.Fill(dados);

            }
            catch (SQLiteException e)
            {
                MessageBox.Show("Erro " + e.Message);
            }
            finally
            {
                con.Close();
            }

            return dados;
        }
开发者ID:victortassinari,项目名称:HundreXSoftwareBlock,代码行数:27,代码来源:excecoesDAO.cs

示例9: pegaExececoes

        public static DataTable pegaExececoes(int bloqueio)
        {
            string sql = "SELECT * FROM excecoes WHERE exc_bloqueio = @bloqueio";
            SQLiteConnection con = conexao.conectar();
            SQLiteCommand cmd = new SQLiteCommand(sql, con);
            cmd.Parameters.Add(new SQLiteParameter("@bloqueio", bloqueio));

            try
            {
                cmd.ExecuteNonQuery();
                SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                DataTable dados = new DataTable();
                da.Fill(dados);
                return dados;
            }
            catch (SQLiteException e)
            {
                MessageBox.Show("Erro " + e.Message);
                return null;
            }
            finally
            {
                con.Close();
            }
        }
开发者ID:victortassinari,项目名称:HundreXSoftwareBlock,代码行数:25,代码来源:excecoesDAO.cs

示例10: ExcuteInsertReturnRowID

 /// <summary>
 /// 对SQLite数据库执行Insert操作,并返回rowID。
 /// </summary>
 /// <param name="sql">要执行的Insert SQL语句</param>
 /// <param name="parameters">执行Insert语句所需要的参数,参数必须以它们在SQL语句中的顺序为准</param>
 /// <returns>RowID</returns>
 public static int ExcuteInsertReturnRowID(string sql, SQLiteParameter[] parameters = null)
 {
     int rowID = -1;
     int affectedRows;
     using (SQLiteConnection connection = new SQLiteConnection(connectionString))
     {
         connection.Open();
         using (DbTransaction transaction = connection.BeginTransaction())
         {
             using (SQLiteCommand command = new SQLiteCommand(connection))
             {
                 command.CommandText = sql;
                 if (parameters != null)
                 {
                     command.Parameters.AddRange(parameters);
                 }
                 affectedRows = command.ExecuteNonQuery();
             }
             transaction.Commit();
         }
         if (affectedRows == 0)
         {
             return rowID;
         }
         string getRowIDSql = "select last_insert_rowid()";
         using (SQLiteCommand getRowIDCmd = new SQLiteCommand(getRowIDSql, connection))
         {
             SQLiteDataAdapter adapter = new SQLiteDataAdapter(getRowIDCmd);
             DataTable data = new DataTable();
             adapter.Fill(data);
             rowID = Convert.ToInt32(data.Rows[0][0]);
         }
     }
     return rowID;
 }
开发者ID:a707937337,项目名称:SalesManager,代码行数:41,代码来源:SQLiteDBHelper.cs

示例11: loadEntsDtBySql

        protected DataTable loadEntsDtBySql(string sql)
        {
            DataTable ret = new DataTable("mytable");

            try
            {
                open();
                SQLiteCommand cmd = new SQLiteCommand();
                cmd.CommandText = sql;
                cmd.Connection = conn;

                SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                da.Fill(ret);

                close();

                return ret;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return ret;
            }
        }
开发者ID:kingleeyc,项目名称:SuperMemory110,代码行数:25,代码来源:CDbBase.cs

示例12: ExecuteDataTable

        /// <summary> 
        /// 执行一个查询语句,返回一个包含查询结果的DataTable 
        /// </summary> 
        /// <param name="sql">要执行的查询语句</param> 
        /// <param name="parameters">执行SQL查询语句所需要的参数,参数必须以它们在SQL语句中的顺序为准</param> 
        /// <returns></returns> 
        public int ExecuteDataTable(StringBuilder sql, SQLiteParameter[] parameters, ref DataTable dt)
        {
            try
            {
                using (SQLiteConnection connection = new SQLiteConnection(connectionString))
                {
                    connection.Open();
                    using (SQLiteCommand command = new SQLiteCommand(sql.ToString(), connection))
                    {
                        if (parameters != null)
                        {
                            command.Parameters.AddRange(parameters);
                        }

                        SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
                        adapter.Fill(dt);
                        return 0;
                    }
                }

            }
            catch (Exception ex)
            {
                return -1;
                throw new Exception(ex.Message);
            }
        }
开发者ID:hanxinlei2002,项目名称:LotteryApp,代码行数:33,代码来源:SQLiteDBHelper.cs

示例13: GetUser

 private DataTable GetUser(string email)
 {
     DataTable datTable = new DataTable();
     StringBuilder sqliteQuerySelect = new StringBuilder();
     sqliteQuerySelect.Append("SELECT ");
     sqliteQuerySelect.Append("id, ");
     sqliteQuerySelect.Append("email, ");
     sqliteQuerySelect.Append("encrypted_password, ");
     sqliteQuerySelect.Append("sign_in_count, ");
     sqliteQuerySelect.Append("current_sign_in_at, ");
     sqliteQuerySelect.Append("last_sign_in_at, ");
     sqliteQuerySelect.Append("last_sign_in_ip, ");
     sqliteQuerySelect.Append("created_at, ");
     sqliteQuerySelect.Append("updated_at, ");
     sqliteQuerySelect.Append("credit_card_id, ");
     sqliteQuerySelect.Append("credit_card_description ");
     sqliteQuerySelect.Append("FROM users ");
     sqliteQuerySelect.Append("WHERE email = @email");
     SQLiteDataAdapter sqliteDataAdapterSelect = new SQLiteDataAdapter();
     sqliteDataAdapterSelect.SelectCommand = new SQLiteCommand();
     sqliteDataAdapterSelect.SelectCommand.Parameters.AddWithValue("@email", email);
     dataAccessObject = new DataAccessLayer();
     datTable = dataAccessObject.Select(sqliteQuerySelect.ToString(), sqliteDataAdapterSelect);
     return datTable;
 }
开发者ID:HansChee,项目名称:rest-api-sample-app-dotnet,代码行数:25,代码来源:AccountController.cs

示例14: SelectQueryNew

		public static DataTable SelectQueryNew (string query, string tablename)
		{
			//http://lists.ximian.com/pipermail/mono-list/2005-June/027584.html
			checkOperatingSystem ();
			/*IDbConnection dbcon;
			dbcon = (IDbConnection) new SqliteConnection(CONstr);
            dbcon.Open();
            IDbCommand dbcmd = dbcon.CreateCommand();
            dbcmd.CommandText = query;
            IDataReader reader = dbcmd.ExecuteReader();
			DataTable dt = new DataTable();
			dt.Load(reader);
			dt.AcceptChanges();*/
			try
			{
				DataTable dt = new DataTable();
				using (SQLiteConnection CON = new SQLiteConnection(CONstr))
				{
					SQLiteCommand CMD = new SQLiteCommand(query, CON);
					DataSet dataset = new DataSet();
					SQLiteDataAdapter AD = new SQLiteDataAdapter(CMD);
					AD.Fill(dataset, tablename);
					dt = dataset.Tables[0];
				}
				return dt;

			}
			catch(Exception Ex)
			{
				return new DataTable();
			}
		}
开发者ID:sumitglobussoft,项目名称:pinDominator-3.0,代码行数:32,代码来源:DatabaseHandler.cs

示例15: CheckcustomerID

        public int CheckcustomerID(int customerid)
        {
            string sql = "select * from Listcustomer where [email protected] ";
            try
            {
                conn.Open();
                SQLiteCommand cmd = new SQLiteCommand(sql, conn);
                cmd.Parameters.AddWithValue("@customerid", customerid);
                SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd);
                DataTable dt = new DataTable();
                adapter.Fill(dt);

                if (dt.Rows.Count>0)
                    return 1;
                else
                    return 0;
            }
            catch (Exception ex)
            {
                return 0;
            }
            finally
            {
                conn.Close();
            }
            return 1;
        }
开发者ID:HaiHien,项目名称:QL,代码行数:27,代码来源:Customershopping.cs


注:本文中的System.Data.SQLite.SQLiteDataAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。