2010年6月30日水曜日

SQLServer Compact Edition

SQLServerCeで行ロックがかかっているかの実験。

using (var connection1 = new SqlCeConnection(Settings.Default.Setting))
using (var connection2 = new SqlCeConnection(Settings.Default.Setting))
{
connection1.Open();
connection2.Open();
var command1 = connection1.CreateCommand();
var command2 = connection2.CreateCommand();
using (var tran1 = connection1.BeginTransaction())
using (var tran2 = connection2.BeginTransaction())
{
command1.Transaction = tran1;
command2.Transaction = tran2;

command1.CommandText = "select * from table1 with (updlock) where id = 1";
command2.CommandText = "select * from table1 with (updlock) where id = 1";

using (var reader1 = command1.ExecuteReader())
using (var reader2 = command2.ExecuteReader())
{
while (reader1.Read() && reader2.Read())
{
Console.WriteLine(reader1.GetInt32(0));
Console.WriteLine(reader2.GetInt32(0));
}
}
}
}


確かに。

0 件のコメント: