TransactionScope Question

TransactionScope Question

Postby KW » Mon 16 Aug 2010 18:54

I want to enlist the connection string used by the System.Web.Security.Membership class and a Devart mysql Connection and Command object.

Do I just use a transcation scope to do this?

For example,

using ( TransacitonScope scope = new TransactionScope)
{
System.Web.Security.Membership.CreateUser(NewCustomerEmail.Text, Password.Text, NewCustomerEmail.Text);

MySqlConnection con = new MySqlConnection("Constring");

MySqlCommand command = new MysqlCommand("UpdateInfo", con);

command.ExecuteNonquery();


}

In the above example, will they both enlist in the same transaction?
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Re: TransactionScope Question

Postby KW » Mon 16 Aug 2010 19:49

with more research you find that the Membership.CreateUser uses its on local transaction.

So when you try to enlist it in a distributed transaction it throws an exception, that you can't enlist in a distributed transaction and a local transaction at the same time.

Is there a way around this?
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Postby Shalex » Tue 17 Aug 2010 11:23

We recommend you using the following overload of the System.Web.Security.Membership.CreateUser() method:
Code: Select all
            System.Web.Security.MembershipCreateStatus status;
            System.Web.Security.Membership.CreateUser("user", "pass!word", "a@a.a", "why?","because",true, out status);
            if (status == System.Web.Security.MembershipCreateStatus.Success) {
                try {
                    using (MySqlConnection con = new MySqlConnection("Constring")) {
                        MySqlCommand command = new MySqlCommand("UpdateInfo", con);
                        con.Open();
                        command.ExecuteNonQuery();
                    }
                }
                catch{
                    System.Web.Security.Membership.DeleteUser("user");
                }
            }
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Postby KW » Tue 17 Aug 2010 17:22

ok, so basically there is no way to really enlist it in a transaction?

Thanks for the input.
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Postby Shalex » Wed 18 Aug 2010 11:07

Internal implementation of Membership Provider creates its own local transaction, but local transactions cannot be enlisted to the distributed transaction. We will investigate the issue to check if it is possible to work around this situation.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Postby Shalex » Thu 19 Aug 2010 08:55

We have fixed bug with enlisting ASP.NET provider's activity to distributed transaction. I will post here when corresponding build is available for download.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Postby KW » Thu 19 Aug 2010 19:25

Shalex wrote:We have fixed bug with enlisting ASP.NET provider's activity to distributed transaction. I will post here when corresponding build is available for download.


Thanks.
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Postby KW » Wed 22 Sep 2010 16:55

KW wrote:
Shalex wrote:We have fixed bug with enlisting ASP.NET provider's activity to distributed transaction. I will post here when corresponding build is available for download.


Thanks.


Do you have a time frame to which this will be released? Thank you.
KW
 
Posts: 117
Joined: Tue 19 Feb 2008 19:12

Postby Shalex » Fri 24 Sep 2010 14:37

New build of dotConnect for MySQL 5.80.170 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/mysql/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=19069 .
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL