Transaction of WebService Method didn't work.
Posted: Thu 27 Jul 2006 10:47
Hi....
I made some webservice using Enterprise Library 2.0 & MySQLDirect .NET.
That code is on below.
------------------------------------------------------------------------------
[WebMethod(TransactionOption = TransactionOption.Required)]
public bool InsertUniverse()
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "insert into Test values (@testid, @testname)";
DbCommand dbcommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbcommand, "@testid", DbType.String, "002");
db.AddInParameter(dbcommand, "@testname", DbType.String, "testtest");
db.ExecuteNonQuery(dbcommand);
dbcommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbcommand, "@testid", DbType.String, "002");
db.AddInParameter(dbcommand, "@testname", DbType.String, "testtest");
db.ExecuteNonQuery(dbcommand);
return true;
}
------------------------------------------------------------------------------
I want that exception occurred and then no low is inserted.
First command is executed and second command occur dup exception but first command is not rollbacked.
Maybe, I think the Transaction configuration of WebMethod ([WebMethod(TransactionOption = TransactionOption.Required)]) didn't work.
This is bug?? If not, why this case is occurred??
I made some webservice using Enterprise Library 2.0 & MySQLDirect .NET.
That code is on below.
------------------------------------------------------------------------------
[WebMethod(TransactionOption = TransactionOption.Required)]
public bool InsertUniverse()
{
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "insert into Test values (@testid, @testname)";
DbCommand dbcommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbcommand, "@testid", DbType.String, "002");
db.AddInParameter(dbcommand, "@testname", DbType.String, "testtest");
db.ExecuteNonQuery(dbcommand);
dbcommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbcommand, "@testid", DbType.String, "002");
db.AddInParameter(dbcommand, "@testname", DbType.String, "testtest");
db.ExecuteNonQuery(dbcommand);
return true;
}
------------------------------------------------------------------------------
I want that exception occurred and then no low is inserted.
First command is executed and second command occur dup exception but first command is not rollbacked.
Maybe, I think the Transaction configuration of WebMethod ([WebMethod(TransactionOption = TransactionOption.Required)]) didn't work.
This is bug?? If not, why this case is occurred??