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


C# SqliteConnection.Open方法代码示例

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


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

示例1: 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

示例2: Initialise

        public void Initialise(string connectionString)
        {
            if (Util.IsWindows())
                Util.LoadArchSpecificWindowsDll("sqlite3.dll");

            m_connectionString = connectionString;

            m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);

            m_connection = new SqliteConnection(m_connectionString);
            m_connection.Open();

            Migration m = new Migration(m_connection, Assembly, "EstateStore");
            m.Update();

            //m_connection.Close();
           // m_connection.Open();

            Type t = typeof(EstateSettings);
            m_Fields = t.GetFields(BindingFlags.NonPublic |
                                   BindingFlags.Instance |
                                   BindingFlags.DeclaredOnly);

            foreach (FieldInfo f in m_Fields)
                if (f.Name.Substring(0, 2) == "m_")
                    m_FieldMap[f.Name.Substring(2)] = f;
        }
开发者ID:JAllard,项目名称:opensim,代码行数:27,代码来源:SQLiteEstateData.cs

示例3: Initialise

        public void Initialise(string connectionString)
        {
            m_connectionString = connectionString;

            m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);

            m_connection = new SqliteConnection(m_connectionString);
            try
            {
                m_connection.Open();
            }
            catch (Exception ex)
            {
                throw new Exception("SQLite has errored out on opening the database. If you are on a 64 bit system, please run OpenSim.32BitLaunch.exe and try again. If this is not a 64 bit error :" + ex);
            }

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(m_connection, assem, "EstateStore");
            m.Update();

            //m_connection.Close();
           // m_connection.Open();

            Type t = typeof(EstateSettings);
            m_Fields = t.GetFields(BindingFlags.NonPublic |
                                   BindingFlags.Instance |
                                   BindingFlags.DeclaredOnly);

            foreach (FieldInfo f in m_Fields)
                if (f.Name.Substring(0, 2) == "m_")
                    m_FieldMap[f.Name.Substring(2)] = f;
        }
开发者ID:NickyPerian,项目名称:Aurora,代码行数:32,代码来源:SQLiteEstateData.cs

示例4: Initialise

        public void Initialise(string connectionString)
        {
            m_connectionString = connectionString;

            m_log.Info("[ESTATE DB]: Sqlite - connecting: "+m_connectionString);

            m_connection = new SqliteConnection(m_connectionString);
            m_connection.Open();

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(m_connection, assem, "EstateStore");
            m.Update();

            //m_connection.Close();
           // m_connection.Open();

            Type t = typeof(EstateSettings);
            m_Fields = t.GetFields(BindingFlags.NonPublic |
                                   BindingFlags.Instance |
                                   BindingFlags.DeclaredOnly);

            foreach (FieldInfo f in m_Fields)
                if (f.Name.Substring(0, 2) == "m_")
                    m_FieldMap[f.Name.Substring(2)] = f;
        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:25,代码来源:SQLiteEstateData.cs

示例5: 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

示例6: Initialise

 public void Initialise(string connectionString)
 {
     if (Util.IsWindows())
         Util.LoadArchSpecificWindowsDll("sqlite3.dll");
     
     m_connectionString = connectionString;
     
     m_log.Info("[PROFILES_DATA]: Sqlite - connecting: "+m_connectionString);
     
     m_connection = new SqliteConnection(m_connectionString);
     m_connection.Open();
     
     Migration m = new Migration(m_connection, Assembly, "UserProfiles");
     m.Update();
 }
开发者ID:justasabc,项目名称:opensim76,代码行数:15,代码来源:SQLiteUserProfilesData.cs

示例7: AssertConnectionOpens

        private static void AssertConnectionOpens(string connectionString, string expectedPath)
        {
            if (File.Exists(expectedPath))
            {
                File.Delete(expectedPath);
            }

            using (var connection = new SqliteConnection(connectionString))
            {
                connection.Open();
                Assert.Equal(expectedPath, connection.DataSource);
            }

            Assert.True(File.Exists(expectedPath));
        }
开发者ID:carloserodriguez2000,项目名称:Microsoft.Data.Sqlite,代码行数:15,代码来源:SqliteConnectionTest.cs

示例8: Initialise

        /// <summary>
        /// <list type="bullet">
        /// <item>Initialises AssetData interface</item>
        /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
        /// <item>use default URI if connect string is empty.</item>
        /// </list>
        /// </summary>
        /// <param name="dbconnect">connect string</param>
        override public void Initialise(string dbconnect)
        {
            if (dbconnect == string.Empty)
            {
                dbconnect = "URI=file:Asset.db,version=3";
            }
            m_conn = new SqliteConnection(dbconnect);
            m_conn.Open();

            Assembly assem = GetType().Assembly;
            Migration m = new Migration(m_conn, assem, "AssetStore");
            m.Update();

            return;
        }
开发者ID:NickyPerian,项目名称:Aurora,代码行数:23,代码来源:SQLiteAssetData.cs

示例9: SQLiteAuthenticationData

        public SQLiteAuthenticationData(string connectionString, string realm)
                : base(connectionString)
        {
            m_Realm = realm;

            if (!m_initialized)
            {
                m_Connection = new SqliteConnection(connectionString);
                m_Connection.Open();

                Migration m = new Migration(m_Connection, Assembly, "AuthStore");
                m.Update();

                m_initialized = true;
            }
        }
开发者ID:NovaGrid,项目名称:opensim,代码行数:16,代码来源:SQLiteAuthenticationData.cs

示例10: LoadNews

        public void LoadNews()
        {
            try
            {
                using (SqliteConnection sqlCnnctn = new SqliteConnection())
                {
                    sqlCnnctn.ConnectionString = _ConnectionString;
                    sqlCnnctn.Open();
                    //
                    using (SqliteCommand sqlCmmndNews = new SqliteCommand())
                    {
                        using (SqliteCommand sqlCmmndEncl = new SqliteCommand())
                        {
                            sqlCmmndNews.Connection = sqlCnnctn;
                            sqlCmmndEncl.Connection = sqlCnnctn;

                            // сваля и зарежда новините
                            foreach (NewsSource ns in _PNews.NSource)
                            {
                                try
                                {
                                    OnLog(LogMessageType.Event, ns.Title);
                                    //
                                    LoadNewsRSS(sqlCmmndNews, sqlCmmndEncl, ns);
                                    //
                                    OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg3_NewsChargedHandle);
                                    TmpNewsRepair(sqlCmmndNews);
                                    //
                                    OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg4_LoadingNews);
                                    TmpNewsTransfer(sqlCmmndNews, sqlCmmndEncl);
                                    //
                                    OnLog(LogMessageType.Event, _PNews.WSaitID.ToString() + _Msg5_Done);
                                }
                                catch (Exception ex)
                                {
                                    OnLog(LogMessageType.Error, "Exception /Load:" + ns.URL + "/: " + ex.Message);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                OnLog(LogMessageType.Error, "Exception: " + ex.Message);
            }
        }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:47,代码来源:ENews.cs

示例11: OnLoad

 static partial void OnLoad()
 {
     if (_isLoaded)
     {
         // prevent re-entrant calls
         return;
     }
     _isLoaded = true;
     if (ApplicationDataHelper.TemporaryFolderPath != null)
     {
         using (var connection = new SqliteConnection("Data Source=:memory:"))
         {
             connection.Open();
             connection.ExecuteNonQuery("PRAGMA temp_store_directory = '" + ApplicationDataHelper.TemporaryFolderPath + "';");
         }
     }
 }
开发者ID:carloserodriguez2000,项目名称:Microsoft.Data.Sqlite,代码行数:17,代码来源:NativeMethods.cs

示例12: SQLiteAuthenticationData

        public SQLiteAuthenticationData(string connectionString, string realm)
                : base(connectionString)
        {
            m_Realm = realm;

            if (!m_initialized)
            {
                if (Util.IsWindows())
                    Util.LoadArchSpecificWindowsDll("sqlite3.dll");

                m_Connection = new SqliteConnection(connectionString);
                m_Connection.Open();

                Migration m = new Migration(m_Connection, Assembly, "AuthStore");
                m.Update();

                m_initialized = true;
            }
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:19,代码来源:SQLiteAuthenticationData.cs

示例13: 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

示例14: btn_Save_Click

 private void btn_Save_Click(object sender, EventArgs e)
 {
     try
     {
         using (SqliteConnection sqlCnnctn = new SqliteConnection())
         {
             sqlCnnctn.ConnectionString = _ConnectionString;
             sqlCnnctn.Open();
             using (SqliteCommand sqlCmmnd = new SqliteCommand())
             {
                 sqlCmmnd.Connection = sqlCnnctn;
                 sqlCmmnd.CommandText =
                     "UPDATE t_news_category " +
                     "    SET n_dscr = @n_dscr " +
                     " WHERE news_category_id = " + _CatID.ToString();
                 sqlCmmnd.Parameters.Add("@n_dscr", DbType.String).Value = tbx_NDscr.Text.Trim();
                 using (SqliteDataReader sqlDReader = sqlCmmnd.ExecuteReader())
                 {
                     if (sqlDReader.HasRows && sqlDReader.Read())
                     {
                         lbl_NCategory.Text = sqlDReader["news_category"].ToString();
                         lbl_NSource.Text = sqlDReader["n_source"].ToString();
                         tbx_NDscr.Text = sqlDReader["n_dscr"].ToString();
                     }
                     sqlDReader.Close();
                 }
             }
             sqlCnnctn.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return;
     }
     Close();
 }
开发者ID:DMSys,项目名称:DotNetUtility,代码行数:37,代码来源:FCategory_Edit.cs

示例15: Transactions_do_not_throw

        public void Transactions_do_not_throw()
        {
            var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "test.db");
            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (var connection = new SqliteConnection("Filename=" + path))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = @"
                DROP TABLE IF EXISTS table1;
                CREATE TABLE table1(Id INTEGER PRIMARY KEY, Value INT);
                INSERT INTO table1 (Value) VALUES ('transaction test');

                BEGIN; -- <<< throws if temp dir not set correctly
                INSERT INTO table1 (Value) VALUES ('value 2');

                CREATE TABLE temp_table2 ( Id INT, Value TEXT);
                INSERT INTO temp_table2 SELECT * FROM table1;";
                    command.ExecuteNonQuery();

                    command.CommandText = "SELECT count(*) from temp_table2;";
                    Assert.Equal(2L, command.ExecuteScalar());

                    command.CommandText = "ROLLBACK;";
                    command.ExecuteNonQuery();

                    command.CommandText = "SELECT count(*) FROM table1;";
                    Assert.Equal(1L, command.ExecuteScalar());
                }
            }
        }
开发者ID:carloserodriguez2000,项目名称:Microsoft.Data.Sqlite,代码行数:36,代码来源:SqliteTransactionTest.cs


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