TransactionScope Question
TransactionScope Question
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?
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?
Re: TransactionScope Question
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?
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?
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", "[email protected]", "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");
}
}
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 .
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 .