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


C# SqliteConnection.CreateCommand方法代码示例

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


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

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

示例2: SqliteDataAdapter

		/// <summary>
		/// Initializes a new instance of the <see cref="SqliteDataAdapter">SqliteDataAdapter</see> class 
		/// with a SelectCommand and a SqliteConnection object.
		/// </summary>
		/// <param name="selectCommandText"></param>
		/// <param name="connection"></param>
		public SqliteDataAdapter(string selectCommandText, SqliteConnection connection)
		{
#if NET_2_0
			DbCommand cmd;
#else
			IDbCommand cmd;
#endif

			cmd = connection.CreateCommand();
			cmd.CommandText = selectCommandText;
			SelectCommand = cmd;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:18,代码来源:SqliteDataAdapter.cs


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