本文整理汇总了C#中SQLiteConnection.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.ExecuteNonQuery方法的具体用法?C# SQLiteConnection.ExecuteNonQuery怎么用?C# SQLiteConnection.ExecuteNonQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.ExecuteNonQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultipleResultSets
public void MultipleResultSets()
{
using (SQLiteConnection conn = new SQLiteConnection(m_csb.ConnectionString))
{
conn.Open();
conn.ExecuteNonQuery(@"create table Test(Id integer not null primary key autoincrement, Value text not null);");
conn.ExecuteNonQuery(@"insert into Test(Id, Value) values(1, 'one'), (2, 'two');");
using (var cmd = (SQLiteCommand) conn.CreateCommand())
{
cmd.CommandText = @"select Value from Test where Id = @First; select Value from Test where Id = @Second;";
cmd.Parameters.Add("First", DbType.Int64).Value = 1L;
cmd.Parameters.Add("Second", DbType.Int64).Value = 2L;
using (var reader = cmd.ExecuteReader())
{
Assert.IsTrue(reader.Read());
Assert.AreEqual("one", reader.GetString(0));
Assert.IsFalse(reader.Read());
Assert.IsTrue(reader.NextResult());
Assert.IsTrue(reader.Read());
Assert.AreEqual("two", reader.GetString(0));
Assert.IsFalse(reader.Read());
Assert.IsFalse(reader.NextResult());
}
}
}
}
示例2: DependentCommands
public void DependentCommands()
{
using (SQLiteConnection conn = new SQLiteConnection(m_csb.ConnectionString))
{
conn.Open();
conn.ExecuteNonQuery(@"create table Test(Id integer not null primary key autoincrement, Value text not null);
create index Test_Value on Test(Value);");
}
}