新的BeginTransaction()之前的ODBCConnection事务检查

时间:2016-01-20 15:31:15

标签: c# transactions odbc openedge progress-db

我通过ODBCConnection类连接到Progress Database。

在开始新的一笔交易之前,如何检查记录中是否有任何未结交易(记录被锁定)?

我的功能:

       Task.Run(() =>
        {
            using (OdbcConnection con = new OdbcConnection("DSN=MY_DSN;UID=root;PWD=qweasd"))
            {
                OdbcCommand command = new OdbcCommand();
                OdbcTransaction transaction = null;

                command.Connection = con;

                try
                {
                    con.Open();
                    AppendLine("Connection...");

                    while (con.State != ConnectionState.Open)
                    {
                        AppendLine(".");
                        Thread.Sleep(10);
                    }
                    AppendLine("");
                    AppendLine("Connected");


                    // THIS IS PLACE WHERE I WANT TO CHECK IF RECORD IS LOCKED


                    transaction = con.BeginTransaction();

                    command.Connection = con;
                    command.Transaction = transaction;

                    command.CommandText = " UPDATE pub.ad_mstr SET ad_line1 = 'Line button3' where ad_mstr.ad_addr = '01010101'  ";

                    command.ExecuteNonQuery();

                    AppendLine("30 seconds dreams");

                    for (int i = 0; i < 30; i++)
                    {
                        Append(".");

                        Thread.Sleep(1000);
                    }


                    transaction.Commit();
                    AppendLine("Commited");

                }
                catch (Exception exc)
                {
                    AppendLine( exc.Data + " " + exc.Source + " " + exc.Message);

                    try
                    {

                    }
                    catch
                    {

                    }
                }

            }
            //_startedTransaction1 = true;
        }); /* Task.Run ( () => */

感谢您的帮助。

0 个答案:

没有答案