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


C# SqliteCommand.ExecuteNonQuery方法代码示例

本文整理汇总了C#中SqliteCommand.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteCommand.ExecuteNonQuery方法的具体用法?C# SqliteCommand.ExecuteNonQuery怎么用?C# SqliteCommand.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SqliteCommand的用法示例。


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

示例1: CreateCrypted

        public void CreateCrypted(string databaseFile)
        {
            try
             {

            // Check if database already exists
            if (!File.Exists (databaseFile))
            {

               // Create the database
               SqliteConnection.CreateFile (databaseFile);

               // Connect to the database

               // using (SqliteConnection sqlCon = GetConnection (String.Format ("Data Source = {0};", databaseFile),"haluk"))
               using (SqliteConnection sqlCon = new SqliteConnection (String.Format ("Data Source = {0}", databaseFile)))

               {
                  sqlCon.SetPassword("haluk");
                  sqlCon.Open ();

                  // Create a table
                  using (SqliteCommand sqlCom = new SqliteCommand (sqlCon))
                  {
                     sqlCom.CommandText = "CREATE TABLE Personel (ID INTEGER PRIMARY KEY, UserName VARCHAR(20), Password VARCHAR(20))";
                     //veri Ekleme
                     //Update
                     //   sqlCom.CommandText = "UPDATE Customers SET FirstName= 'Haluk' WHERE LastName = @lastName";
                     // sqlCom.Parameters.Add(new SqliteParameter("@lastName","Haluky"));

                     sqlCom.ExecuteNonQuery ();

                     Console.WriteLine(sqlCom.ExecuteNonQuery());
                  }
                  //end using sqlCom

                  sqlCon.Close ();

               }
               //end using sqlCon

               this.durumGostericiT.Text = "Database hazır!";

            }else
            {

               this.durumGostericiT.Text = "Database Mevcut!";

            }//end if else

             } catch (Exception ex)
             {

            this.durumGostericiT.Text = String.Format ("Sqlite error: {0}", ex.Message);

             }//end try catch
        }
开发者ID:hhempel,项目名称:StoryboardTables,代码行数:57,代码来源:CryptX.cs

示例2: btnIN_Click

        /// <summary>
        /// Добавя категория
        /// </summary>
        private void btnIN_Click(object sender, EventArgs e)
        {
            if ((cbTNCategoriesSub.SelectedValue == null)
              || cbTNCategoriesSub.SelectedValue.ToString().Equals(""))
            { return; }
            if (dgvCatOUT.CurrentRow == null)
            { return; }
            Int32 iCategoryID = Convert.ToInt32(dgvCatOUT.CurrentRow.Cells["gcCategoryID_OUT"].Value);
            try
            {
                using (SqliteConnection sqlCnnctn = new SqliteConnection())
                {
                    sqlCnnctn.ConnectionString = _ConnectionString;
                    sqlCnnctn.Open();

                    using (SqliteCommand sqlCmmnd = new SqliteCommand())
                    {
                        sqlCmmnd.Connection = sqlCnnctn;
                        sqlCmmnd.CommandText =
                            "UPDATE x_news_nweb " +
                            "    SET nweb_category_id = " + cbTNCategoriesSub.SelectedValue.ToString() +
                            " WHERE news_category_id = " + iCategoryID.ToString();
                        sqlCmmnd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cbTNCategoriesSub_SelectedIndexChanged(null, null);
        }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:35,代码来源:UCCategories.cs

示例3: btnDeleteInvalidEntries_Click

        /// <summary>
        /// Изтрива невалидни записи
        /// </summary>
        private void btnDeleteInvalidEntries_Click(object sender, EventArgs e)
        {
            try
            {
                listBox1.Items.Clear();
                SetMessage("Старт: Изтрива невалидни записи");

                using (SqliteConnection sqlCnnctn = new SqliteConnection())
                {
                    sqlCnnctn.ConnectionString = _ConnectionString;
                    sqlCnnctn.Open();

                    using (SqliteCommand sqlCmmnd = new SqliteCommand())
                    {
                        sqlCmmnd.Connection = sqlCnnctn;

                        // Новини без картинки
                        sqlCmmnd.CommandText =
                            "DELETE FROM news " +
                            " WHERE news_id NOT IN (SELECT DISTINCT news_id FROM enclosure ) ";
                        Int32 iRows = sqlCmmnd.ExecuteNonQuery();
                        SetMessage("Изтити новини без картинки: " + iRows.ToString());

                        // Картинки без новини
                        sqlCmmnd.CommandText =
                            "DELETE FROM enclosure " +
                            " WHERE news_id NOT IN (SELECT news_id FROM news) ";
                        iRows = sqlCmmnd.ExecuteNonQuery();

                        SetMessage("Изтити картинки без новини: " + iRows.ToString());
                    }
                    sqlCnnctn.Close();
                }
                SetMessage("Край");
            }
            catch (Exception ex)
            {
                SetMessage(ex.Message);
            }
        }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:43,代码来源:UCTools.cs

示例4: ExecuteNonQuery

        //////////////////////////////////////////////////////////////
        //
        // All non queries are funneled through one connection
        // to increase performance a little
        //
        protected int ExecuteNonQuery(SqliteCommand cmd, SqliteConnection connection)
        {
            lock (connection)
            {
/*
                SqliteConnection newConnection =
                        (SqliteConnection)((ICloneable)connection).Clone();
                newConnection.Open();

                cmd.Connection = newConnection;
*/
                cmd.Connection = connection;
                //Console.WriteLine("XXX " + cmd.CommandText);

                return cmd.ExecuteNonQuery();
            }
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:22,代码来源:SQLiteFramework.cs

示例5: AddNewCategory

        /// <summary>
        /// Добавя новите категории
        /// </summary>
        private void AddNewCategory(SqliteCommand aSQLCmmnd)
        {
            aSQLCmmnd.CommandText =
                "INSERT INTO t_news_category " +
                " ( news_category_id, news_category, news_site_id ) " +
                " SELECT (SELECT ifnull(MAX(news_category_id),0) +1 FROM t_news_category) " +
                "      , news_category " +
                "      , news_site_id " +
                " FROM tmp_news nws " +
                " WHERE ifnull(nws.news_category_id, 0) = 0 " +
                " LIMIT 1 ";

            aSQLCmmnd.ExecuteNonQuery();
        }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:17,代码来源:ENews.cs

示例6: TmpNewsRepair

        /// <summary>
        /// Обработва новните във временните таблици
        /// </summary>
        public void TmpNewsRepair(SqliteCommand aCmmndNews)
        {
            // Изтрива старите новини
            aCmmndNews.CommandText =
               "DELETE FROM tmp_news " +
               " WHERE news_pubdate < @FromDate ";
            aCmmndNews.Parameters.Clear();
            aCmmndNews.Parameters.Add("@FromDate", DbType.Date).Value = DateTime.Now.AddMonths(-1);
            aCmmndNews.ExecuteNonQuery();

            // Изтрива новини с бъдеща дата
            aCmmndNews.CommandText =
               "DELETE FROM tmp_news " +
               " WHERE news_pubdate > @FromDate ";
            aCmmndNews.Parameters.Clear();
            aCmmndNews.Parameters.Add("@FromDate", DbType.Date).Value = DateTime.Now.AddDays(1);
            aCmmndNews.ExecuteNonQuery();
            //
            aCmmndNews.Parameters.Clear();
            // Изтрива дублиращите се новини
            aCmmndNews.CommandText =
                "DELETE FROM tmp_news " +
                " WHERE tmp_news.news_id in (SELECT tmp_news.news_id " +
                                           " FROM news " +
                                           " INNER JOIN tmp_news " +
                                           "    ON (news.news_guid = tmp_news.news_guid) " +
                                           "   AND (news.news_site_id = tmp_news.news_site_id)); ";
            aCmmndNews.ExecuteNonQuery();

            // Изтрива новините без картинки
            aCmmndNews.CommandText =
                "DELETE FROM tmp_news " +
                " WHERE news_id NOT IN ( SELECT news_id FROM tmp_enclosure ) ";
            OnLog(LogMessageType.Event, "- Изтрити новините без картинки: " + aCmmndNews.ExecuteNonQuery().ToString());

            // Новини за добавяне
            using (DataTable dtNews = new DataTable())
            {
                aCmmndNews.CommandText =
                    "SELECT tmp_news.news_id " +
                    " FROM tmp_news ";
                using (SqliteDataAdapter sqlDAdapter = new SqliteDataAdapter(aCmmndNews))
                {
                    dtNews.Clear();
                    sqlDAdapter.Fill(dtNews);
                }
                // Ако няма новини - КРАЙ
                if (dtNews.Rows.Count == 0)
                { return; }
            }
            // Определя типа на Enclosure
            aCmmndNews.CommandText =
                "UPDATE tmp_enclosure  " +
                "   SET encl_id = (SELECT encl.encl_id " +
                                 " FROM t_enclosure encl " +
                                 " WHERE tmp_enclosure.encl_type = encl.encl_type); ";
            aCmmndNews.ExecuteNonQuery();

            // Проверка за непознат тип на Enclosure
            aCmmndNews.CommandText = "SELECT tmp_enclosure.encl_type "
                                   + " FROM tmp_enclosure "
                                   + " WHERE ( tmp_enclosure.encl_id = 0 ); ";
            using (SqliteDataReader dr = aCmmndNews.ExecuteReader())
            {
                if (dr.HasRows)
                {
                    string sMsg = "Неразпознат тип на 'Enclosure' !";
                    if (dr.Read())
                    {
                        sMsg += dr["encl_type"].ToString();
                    }
                    throw new Exception(sMsg);
                }
                dr.Close();
            }

            // Категории на новините
            /* прецаква кодовата таблица
            // Стандартизира news_category
            aCmmndNews.CommandText =
                    "UPDATE tmp_news " +
                    " SET news_category = lower(trim(news_category)); ";
            aCmmndNews.ExecuteNonQuery();
            */

            // Определя категориите на новините
            SetNewsCategory(aCmmndNews);
            while (HasNewCategory(aCmmndNews))
            {
                AddNewCategory(aCmmndNews);
                SetNewsCategory(aCmmndNews);
            }
            // Връзка м/у таблициците с категории
            aCmmndNews.CommandText =
                "INSERT INTO x_news_nweb " +
                " ( news_category_id, nweb_category_id ) " +
                " SELECT nct.news_category_id " +
//.........这里部分代码省略.........
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:101,代码来源:ENews.cs

示例7: TmpNewsTransfer

        /// <summary>
        /// Зарежда новите новини
        /// </summary>
        public void TmpNewsTransfer(SqliteCommand aCmmndNews, SqliteCommand aCmmndEncl)
        {
            DataTable dtNews = new DataTable();

            aCmmndNews.CommandText =
                "SELECT tmp_news.news_id FROM tmp_news ";
            using (SqliteDataAdapter sqlDAdapter = new SqliteDataAdapter(aCmmndNews))
            {
                dtNews.Clear();
                sqlDAdapter.Fill(dtNews);
            }

            // Ако няма новини - КРАЙ
            if (dtNews.Rows.Count == 0)
            { return; }

            Int32 iNewsID = 0;
            // ID на последната новина
            aCmmndNews.CommandText =
                "SELECT ifnull(max(news.news_id),0) AS news_id " +
                " FROM news ";
            using (SqliteDataReader dr = aCmmndNews.ExecuteReader())
            {
                if (dr.HasRows && dr.Read())
                {
                    if (dr["news_id"].ToString().Equals(""))
                    {
                        iNewsID = 1;
                    }
                    else
                    {
                        iNewsID = Convert.ToInt32(dr["news_id"]) + 1;
                    }
                }
                else
                {
                    throw new Exception("Exception: TmpNewsTransfer");
                }
                dr.Close();
            }

            // Новини
            aCmmndNews.CommandText = "INSERT INTO news ( news_id, news_site_id, news_guid, news_title, news_link, news_description, news_body, news_comments, news_pubdate, news_category_id ) "
                                   + " SELECT @news_id "
                                   + "      , tmp_news.news_site_id "
                                   + "      , tmp_news.news_guid "
                                   + "      , tmp_news.news_title "
                                   + "      , tmp_news.news_link "
                                   + "      , tmp_news.news_description "
                                   + "      , tmp_news.news_body "
                                   + "      , tmp_news.news_comments "
                                   + "      , tmp_news.news_pubdate "
                                   + "      , tmp_news.news_category_id "
                                   + " FROM tmp_news "
                                   + " WHERE ( tmp_news.news_id = @tmp_news_id ); ";
            aCmmndNews.Parameters.Clear();
            aCmmndNews.Parameters.Add("@news_id", DbType.Int32);
            aCmmndNews.Parameters.Add("@tmp_news_id", DbType.Int32);

            // Новини - Картинки
            aCmmndEncl.CommandText = "INSERT INTO enclosure ( news_id, encl_link, encl_id ) "
                                   + " SELECT @news_id "
                                   + "      , tmp_enclosure.encl_link "
                                   + "      , tmp_enclosure.encl_id "
                                   + " FROM tmp_enclosure "
                                   + " WHERE ( tmp_enclosure.news_id = @tmp_news_id ); ";
            aCmmndEncl.Parameters.Clear();
            aCmmndEncl.Parameters.Add("@news_id", DbType.Int32);
            aCmmndEncl.Parameters.Add("@tmp_news_id", DbType.Int32);

            foreach (DataRow dr in dtNews.Rows)
            {
                //
                aCmmndNews.Parameters["@news_id"].Value = iNewsID;
                aCmmndNews.Parameters["@tmp_news_id"].Value = dr["news_id"];

                aCmmndNews.ExecuteNonQuery();

                aCmmndEncl.Parameters["@news_id"].Value = iNewsID;
                aCmmndEncl.Parameters["@tmp_news_id"].Value = dr["news_id"];

                aCmmndEncl.ExecuteNonQuery();

                iNewsID++;
            }
        }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:89,代码来源:ENews.cs

示例8: StoreTerrain

        /// <summary>
        /// Store a terrain revision in region storage
        /// </summary>
        /// <param name="ter">terrain heightfield</param>
        /// <param name="regionID">region UUID</param>
        public void StoreTerrain(double[,] ter, UUID regionID)
        {
            lock (ds)
            {
                int revision = Util.UnixTimeSinceEpoch();

                // This is added to get rid of the infinitely growing
                // terrain databases which negatively impact on SQLite
                // over time.  Before reenabling this feature there
                // needs to be a limitter put on the number of
                // revisions in the database, as this old
                // implementation is a DOS attack waiting to happen.

                using (
                    SqliteCommand cmd =
                        new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
                                          m_conn))
                {
                    cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
                    cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
                    cmd.ExecuteNonQuery();
                }

                // the following is an work around for .NET.  The perf
                // issues associated with it aren't as bad as you think.
                m_log.Debug("[SQLITE REGION DB]: Storing terrain revision r" + revision.ToString());
                String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
                             " values(:RegionUUID, :Revision, :Heightfield)";

                using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
                {
                    cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
                    cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
                    cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
                    cmd.ExecuteNonQuery();
                }
            }
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:43,代码来源:SQLiteSimulationData.cs

示例9: Delete

 /// <summary>
 /// Delete an asset from database
 /// </summary>
 /// <param name="uuid"></param>
 public override bool Delete(string id)
 {
     lock (this)
     {
         using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn))
         {
             cmd.Parameters.Add(new SqliteParameter(":UUID", id));
             cmd.ExecuteNonQuery();
         }
     }
     return true;
 }
开发者ID:NickyPerian,项目名称:Aurora,代码行数:16,代码来源:SQLiteAssetData.cs

示例10: DoLoad

        private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create)
        {
            EstateSettings es = new EstateSettings();
            es.OnSave += StoreEstateSettings;
            IDataReader r = null;
            try
            {
                 r = cmd.ExecuteReader();
            }
            catch (SqliteException)
            {
                m_log.Error("[SQLITE]: There was an issue loading the estate settings.  This can happen the first time running OpenSimulator with CSharpSqlite the first time.  OpenSimulator will probably crash, restart it and it should be good to go.");
            }

            if (r != null && r.Read())
            {
                foreach (string name in FieldList)
                {
                    if (m_FieldMap[name].GetValue(es) is bool)
                    {
                        int v = Convert.ToInt32(r[name]);
                        if (v != 0)
                            m_FieldMap[name].SetValue(es, true);
                        else
                            m_FieldMap[name].SetValue(es, false);
                    }
                    else if (m_FieldMap[name].GetValue(es) is UUID)
                    {
                        UUID uuid = UUID.Zero;

                        UUID.TryParse(r[name].ToString(), out uuid);
                        m_FieldMap[name].SetValue(es, uuid);
                    }
                    else
                    {
                        m_FieldMap[name].SetValue(es, Convert.ChangeType(r[name], m_FieldMap[name].FieldType));
                    }
                }
                r.Close();
            }
            else if (create)
            {
                r.Close();

                List<string> names = new List<string>(FieldList);

                names.Remove("EstateID");

                string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";

                cmd.CommandText = sql;
                cmd.Parameters.Clear();

                foreach (string name in FieldList)
                {
                    if (m_FieldMap[name].GetValue(es) is bool)
                    {
                        if ((bool)m_FieldMap[name].GetValue(es))
                            cmd.Parameters.AddWithValue(":"+name, "1");
                        else
                            cmd.Parameters.AddWithValue(":"+name, "0");
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue(":"+name, m_FieldMap[name].GetValue(es).ToString());
                    }
                }

                cmd.ExecuteNonQuery();

                cmd.CommandText = "select LAST_INSERT_ROWID() as id";
                cmd.Parameters.Clear();

                r = cmd.ExecuteReader();

                r.Read();

                es.EstateID = Convert.ToUInt32(r["id"]);

                r.Close();

                cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
                cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
                cmd.Parameters.AddWithValue(":EstateID", es.EstateID.ToString());

                // This will throw on dupe key
                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception)
                {
                }

                es.Save();
            }

            LoadBanList(es);

            es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:101,代码来源:SQLiteEstateData.cs

示例11: btn_Optimization_Click

        /// <summary>
        /// Оптимиьира базата
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Optimization_Click(object sender, EventArgs e)
        {
            try
            {
                listBox1.Items.Clear();
                SetMessage("Старт: Оптимизация");

                using (SqliteConnection sqlCnnctn = new SqliteConnection())
                {
                    sqlCnnctn.ConnectionString = _ConnectionString;
                    sqlCnnctn.Open();

                    using (SqliteCommand sqlCmmnd = new SqliteCommand())
                    {
                        sqlCmmnd.Connection = sqlCnnctn;

                        SetMessage("Старт: ReIndex");
                        sqlCmmnd.CommandText = "REINDEX;";
                        sqlCmmnd.ExecuteNonQuery();
                        SetMessage("Край: ReIndex");

                        SetMessage("Старт: Compact the database");
                        sqlCmmnd.CommandText = "VACUUM;";
                        sqlCmmnd.ExecuteNonQuery();
                        SetMessage("Край: Compact the database");
                    }
                    sqlCnnctn.Close();
                }
                SetMessage("Край: Оптимизация");
            }
            catch (Exception ex)
            {
                SetMessage(ex.Message);
            }
        }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:40,代码来源:UCTools.cs

示例12: StoreTerrain

        /// <summary>
        /// Store a terrain revision in region storage
        /// </summary>
        /// <param name="ter">terrain heightfield</param>
        /// <param name="regionID">region UUID</param>
        public void StoreTerrain(TerrainData terrData, UUID regionID)
        {
            lock (ds)
            {
                using (
                    SqliteCommand cmd = new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID", m_conn))
                {
                    cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
                    cmd.ExecuteNonQuery();
                }

                // the following is an work around for .NET.  The perf
                // issues associated with it aren't as bad as you think.
                String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
                             " values(:RegionUUID, :Revision, :Heightfield)";

                int terrainDBRevision;
                Array terrainDBblob;
                terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);

                m_log.DebugFormat("{0} Storing terrain revision r {1}", LogHeader, terrainDBRevision);

                using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
                {
                    cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
                    cmd.Parameters.Add(new SqliteParameter(":Revision", terrainDBRevision));
                    cmd.Parameters.Add(new SqliteParameter(":Heightfield", terrainDBblob));
                    cmd.ExecuteNonQuery();
                }
            }
        }
开发者ID:szielins,项目名称:opensim,代码行数:36,代码来源:SQLiteSimulationData.cs

示例13: StoreAsset

        /// <summary>
        /// Create an asset
        /// </summary>
        /// <param name="asset">Asset Base</param>
        override public void StoreAsset(AssetBase asset)
        {
            //m_log.Info("[ASSET DB]: Creating Asset " + asset.FullID.ToString());
            if (ExistsAsset(asset.FullID))
            {
                //LogAssetLoad(asset);

                lock (this)
                {
                    using (SqliteCommand cmd = new SqliteCommand(UpdateAssetSQL, m_conn))
                    {
                        cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString()));
                        cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
                        cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
                        cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
                        cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
                        cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
                        cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
                        cmd.Parameters.Add(new SqliteParameter(":CreatorID", asset.Metadata.CreatorID));
                        cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            else
            {
                lock (this)
                {
                    using (SqliteCommand cmd = new SqliteCommand(InsertAssetSQL, m_conn))
                    {
                        cmd.Parameters.Add(new SqliteParameter(":UUID", asset.FullID.ToString()));
                        cmd.Parameters.Add(new SqliteParameter(":Name", asset.Name));
                        cmd.Parameters.Add(new SqliteParameter(":Description", asset.Description));
                        cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type));
                        cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local));
                        cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary));
                        cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags));
                        cmd.Parameters.Add(new SqliteParameter(":CreatorID", asset.Metadata.CreatorID));
                        cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data));

                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }
开发者ID:JAllard,项目名称:opensim,代码行数:50,代码来源:SQLiteAssetData.cs

示例14: SetLastSendNews

 private void SetLastSendNews(SqliteConnection aSqlCnnctn)
 {
     using (SqliteCommand sqlCmmnd = new SqliteCommand())
     {
         sqlCmmnd.Connection = aSqlCnnctn;
         Int64 iLastSendNews = 0;
         sqlCmmnd.CommandText =
             "SELECT MAX(news.news_id) AS max_news_id FROM news ";
         using (SqliteDataReader sqlDReader = sqlCmmnd.ExecuteReader())
         {
             if (sqlDReader.HasRows && sqlDReader.Read())
             {
                 iLastSendNews = Convert.ToInt64(sqlDReader["max_news_id"]);
             }
             sqlDReader.Close();
         }
         //
         sqlCmmnd.CommandText = "UPDATE news_setting "
                              + "    SET prm_value_int = " + iLastSendNews.ToString()
                              + " WHERE prm_name = 'last_send_news' ";
         sqlCmmnd.ExecuteNonQuery();
     }
 }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:23,代码来源:UCUpdateData.cs

示例15: OnCreate

        protected override void OnCreate(Bundle bundle) {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };

            #region ADDED TO SAMPLE TO DEMONSTRATE Portable.Data.Sqlite

            string myTableName = "TestTable1";
            string sql;

            //Instantiate my "crypt engine"
            this.AppCryptEngine = this.AppCryptEngine ?? new FakeCryptEngine(this.AppPassword);

            #region Part 1 - ADO - Create a table, add a record, add a column, add encrypted data, read back data

            using (var dbConn = new SqliteAdoConnection(this.SqliteConnection, this.AppCryptEngine)) {

                Console.WriteLine("PART 1 - Doing ADO stuff");

                //Create the table if it doesn't exist
                sql = "CREATE TABLE IF NOT EXISTS " + myTableName + " (IdColumn INTEGER PRIMARY KEY AUTOINCREMENT, DateTimeColumn DATETIME, TextColumn TEXT);";
                using (var cmd = new SqliteCommand(sql, dbConn)) {
                    dbConn.SafeOpen();
                    cmd.ExecuteNonQuery();
                    Console.WriteLine("Table [" + myTableName + "] created (if it didn't exist).");
                }

                //Add a record
                sql = "INSERT INTO " + myTableName + " (DateTimeColumn, TextColumn) VALUES (@date, @text);";
                int newRowId;
                using (var cmd = new SqliteCommand(sql, dbConn)) {
                    cmd.Parameters.Add(new SqliteParameter("@date", DateTime.Now));
                    cmd.Parameters.Add(new SqliteParameter("@text", "Hello SQLite."));
                    dbConn.SafeOpen();
                    newRowId = Convert.ToInt32(cmd.ExecuteReturnRowId());  //Note: INTEGER columns in SQLite are always long/Int64 - including ID columns, so converting to int
                    Console.WriteLine("A record with ID " + newRowId.ToString() + " was created in table [" + myTableName + "].");
                }

                //Read the datetime column on the oldest record
                sql = "SELECT [DateTimeColumn] FROM " + myTableName + " ORDER BY [DateTimeColumn] LIMIT 1;";
                using (var cmd = new SqliteCommand(sql, dbConn)) {
                    dbConn.SafeOpen();
                    DateTime oldest = Convert.ToDateTime(cmd.ExecuteScalar());
                    Console.WriteLine("The oldest record in table [" + myTableName + "] has timestamp: " + oldest.ToString());
                }

                //Add an encrypted column to the table
                //NOTE: There is no benefit to creating the column as SQLite datatype ENCRYPTED vs. TEXT
                //  It is actually a TEXT column - but I think it is nice to set it to type ENCRYPTED for future purposes.
                //  Hopefully a future version of SQLitePCL will make it easy to figure out if a column is defined as ENCRYPTED or TEXT
                //  (right now, it identifies both as TEXT)
                sql = "ALTER TABLE " + myTableName + " ADD COLUMN EncryptedColumn ENCRYPTED;";
                //Note: This column shouldn't exist until the above sql is run, since I just created the table above.  But if this application has been run multiple times, 
                //  the column may already exist in the table - so I need to check for it.
                bool columnAlreadyExists = false;
                #region Check for column
                using (var checkCmd = new SqliteCommand(dbConn)) {
                    checkCmd.CommandText = "PRAGMA table_info (" + myTableName + ");";
                    dbConn.SafeOpen();
                    using (var checkDr = new SqliteDataReader(checkCmd)) {
                        while (checkDr.Read()) {
                            if (checkDr.GetString("NAME") == "EncryptedColumn") {
                                Console.WriteLine("The [EncryptedColumn] column already exists.");
                                columnAlreadyExists = true;
                                break;
                            }
                        }
                    }
                }
                #endregion
                if (!columnAlreadyExists) {
                    using (var cmd = new SqliteCommand(sql, dbConn)) {
                        dbConn.SafeOpen();
                        cmd.ExecuteNonQuery();
                        Console.WriteLine("The [EncryptedColumn] column was created in table [" + myTableName + "].");
                    }
                }

                //Add a record with an encrypted column value
                sql = "INSERT INTO " + myTableName + " (DateTimeColumn, TextColumn, EncryptedColumn) VALUES (@date, @text, @encrypted);";
                using (var cmd = new SqliteCommand(sql, dbConn)) {
                    cmd.Parameters.Add(new SqliteParameter("@date", DateTime.Now));
                    cmd.Parameters.Add(new SqliteParameter("@text", "Hello data."));
                    cmd.AddEncryptedParameter(new SqliteParameter("@encrypted",
                        Tuple.Create<string, string, string>("Hello", "encrypted", "data")));
                    dbConn.SafeOpen();
                    newRowId = Convert.ToInt32(cmd.ExecuteReturnRowId());  //Note: INTEGER columns in SQLite are always long/Int64 - including ID columns, so converting to int
                    Console.WriteLine("A record featuring encrypted data with ID " + newRowId.ToString() + " was created in table [" + myTableName + "].");
                }

                //Get the value of the encrypted column
                sql = "SELECT [EncryptedColumn] FROM " + myTableName + " WHERE [IdColumn] = @id;";
                using (var cmd = new SqliteCommand(sql, dbConn)) {
//.........这里部分代码省略.........
开发者ID:lhughey,项目名称:Portable.Data.Sqlite,代码行数:101,代码来源:MainActivity.cs


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