本文整理汇总了C#中System.Data.SQLite.SQLiteConnection.BeginTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.SQLite.SQLiteConnection.BeginTransaction方法的具体用法?C# System.Data.SQLite.SQLiteConnection.BeginTransaction怎么用?C# System.Data.SQLite.SQLiteConnection.BeginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnection
的用法示例。
在下文中一共展示了System.Data.SQLite.SQLiteConnection.BeginTransaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateDatabaseWithArteProps
public void UpdateDatabaseWithArteProps( string ConnectionString )
{
System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection( ConnectionString );
conn.Open();
System.Data.SQLite.SQLiteTransaction transaction = conn.BeginTransaction();
System.Data.SQLite.SQLiteCommand command = new System.Data.SQLite.SQLiteCommand( conn );
command.Transaction = transaction;
foreach ( var a in ArteList ) {
string UpdateNames = "UPDATE Text SET IdentifyString = \"" + a.Type.ToString() + ";\" || IdentifyString WHERE IdentifyString LIKE \"%[" + a.NameStringDicId + " / 0x" + a.NameStringDicId.ToString( "X6" ) + "]\"";
Console.WriteLine( UpdateNames );
command.CommandText = UpdateNames;
command.ExecuteNonQuery();
string UpdateDescs = "UPDATE Text SET IdentifyString = \"Description;\" || IdentifyString WHERE IdentifyString LIKE \"%[" + a.DescStringDicId + " / 0x" + a.DescStringDicId.ToString( "X6" ) + "]\"";
Console.WriteLine( UpdateDescs );
command.CommandText = UpdateDescs;
command.ExecuteNonQuery();
if ( a.Type == Arte.ArteType.Generic ) {
string UpdateStatus = "UPDATE Text SET status = 4, updated = 1, updatedby = \"[HyoutaTools]\", updatedtimestamp = " + Util.DateTimeToUnixTime( DateTime.UtcNow ) + " WHERE IdentifyString LIKE \"%[" + a.NameStringDicId + " / 0x" + a.NameStringDicId.ToString( "X6" ) + "]\"";
Console.WriteLine( UpdateStatus );
command.CommandText = UpdateStatus;
command.ExecuteNonQuery();
}
}
command.Dispose();
transaction.Commit();
conn.Close();
conn.Dispose();
}
示例2: Execute
public static int Execute( List<string> args )
{
// 0xCB20
if ( args.Count != 2 ) {
Console.WriteLine( "Generates a scenario db for use in Tales.Vesperia.Website from a MAPLIST.DAT." );
Console.WriteLine( "Usage: maplist.dat scenario.db" );
return -1;
}
String maplistFilename = args[0];
string connStr = "Data Source=" + args[1];
using ( var conn = new System.Data.SQLite.SQLiteConnection( connStr ) ) {
conn.Open();
using ( var ta = conn.BeginTransaction() ) {
SqliteUtil.Update( ta, "CREATE TABLE descriptions( filename TEXT PRIMARY KEY, shortdesc TEXT, desc TEXT )" );
int i = 0;
foreach ( MapName m in new MapList( System.IO.File.ReadAllBytes( maplistFilename ) ).MapNames ) {
Console.WriteLine( i + " = " + m.ToString() );
List<string> p = new List<string>();
p.Add( "VScenario" + i );
p.Add( m.Name1 != "dummy" ? m.Name1 : m.Name3 );
p.Add( m.Name1 != "dummy" ? m.Name1 : m.Name3 );
SqliteUtil.Update( ta, "INSERT INTO descriptions ( filename, shortdesc, desc ) VALUES ( ?, ?, ? )", p );
++i;
}
ta.Commit();
}
conn.Close();
}
return 0;
}
示例3: ProcessSniff
public static void ProcessSniff(string filename, string todir)
{
var clientbuild = 0u;
var accountname = string.Empty;
var logstarted = DateTime.Now;
bool found = false;
bool empty = false;
using (var findcon = new System.Data.SQLite.SQLiteConnection())
{
findcon.ConnectionString = "Data Source=" + filename;
findcon.Open();
using (var tSQLiteCommand = findcon.CreateCommand())
{
var CMSG_AUTH_SESSION = 0x1ED;
tSQLiteCommand.CommandText = string.Format("select id, timestamp, direction, opcode, data from packets where opcode = {0} limit 1", CMSG_AUTH_SESSION);
using (var tempreader = tSQLiteCommand.ExecuteReader())
{
while (tempreader.Read())
{
var id = tempreader.GetInt32(0);
logstarted = tempreader.GetDateTime(1);
var direction = tempreader.GetInt32(2);
var opcode = tempreader.GetInt32(3);
var blob = (byte[])tempreader.GetValue(4);
using (var qs = new Reading.ReadingBase(blob))
{
found = true;
clientbuild = qs.ReadUInt32();
qs.ReadUInt32();
accountname = qs.ReadCString();
if (accountname.IsEmpty())
{
Console.WriteLine("Error");
}
break;
}
}
tempreader.Close();
empty = (clientbuild == 0);
}
}
if (!empty)
{
if (!found) throw new Exception("Invalid file");
string newdir = string.Format("{0}{1}\\", todir, clientbuild);
string newfile = string.Format(@"{0}{1}_{2}_{3}.sqlite", newdir, logstarted.ToString("yyyy-MM-dd-HH-mm"), clientbuild, accountname);
if (System.IO.File.Exists(newfile)) System.IO.File.Delete(newfile);// throw new Exception("File exists");
if (!System.IO.Directory.Exists(newdir)) System.IO.Directory.CreateDirectory(newdir);
System.Data.SQLite.SQLiteConnection.CreateFile(newfile);
var builder = new System.Data.SQLite.SQLiteConnectionStringBuilder();
builder.DataSource = newfile;
builder.CacheSize = builder.CacheSize * 100;
builder.PageSize = builder.PageSize * 100;
builder.JournalMode = System.Data.SQLite.SQLiteJournalModeEnum.Off;
builder.Pooling = false;
DateTime tstart = DateTime.Now;
using (var con = new System.Data.SQLite.SQLiteConnection(builder.ConnectionString))
{
con.Open();
//create tables
var sb = new StringBuilder();
sb.AppendLine("create table packets (id integer primary key autoincrement, timestamp datetime, direction integer, opcode integer, data blob);");
sb.AppendLine("create table header (key string primary key, value string);");
sb.AppendLine(string.Format("insert into header(key, value) values ('clientBuild', '{0}');", clientbuild));
sb.AppendLine("insert into header(key, value) values ('clientLang', 'enUS');");
sb.AppendLine(string.Format("insert into header(key, value) values ('accountName', '{0}');", accountname));
using (System.Data.SQLite.SQLiteCommand command = con.CreateCommand())
{
command.CommandText = sb.ToString();
command.ExecuteNonQuery();
}
Console.WriteLine("start processing newfile: {0} filename: {1}", tstart, newfile);
try
{
using (var dbTrans = con.BeginTransaction())
{
using (var command = con.CreateCommand())
{
//.........这里部分代码省略.........
示例4: UpdateSqLiteDB
private void UpdateSqLiteDB(List<long> docGroupIds)
{
string connectionString = "data source=" + Arguments.SQLiteDataFile;
using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection(connectionString))
{
con.Open();
using (System.Data.SQLite.SQLiteTransaction tran = con.BeginTransaction())
{
using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
{
foreach (int id in docGroupIds)
{
com.CommandText = " UPDATE DocumentGroups SET Operation=3 WHERE DocumentGroupId = " + id;
com.ExecuteNonQuery();
com.CommandText = " UPDATE Documents SET Operation=3 WHERE DocumentGroupId = " + id;
com.ExecuteNonQuery();
}
}
tran.Commit();
}
}
}