i recently change to use Microsoft.Practices.EnterpriseLibrary.Data to access my database instead of using system.data.sqlclient.
and what i need now is to insert multiple insert statement to Database.
Below is my code,
Database db = DatabaseFactory.CreateDatabase();
DbConnection dbConnection = db.CreateConnection();
DbTransaction dbTran = dbConnection.BeginTransaction();
DbCommand dbGroup =db.GetStoredProcCommand("insGroup");
dbGroup.CommandType = CommandType.StoredProcedure;
dbGroup.Transaction = dbTran;
DbCommand dbDet =db.GetStoredProcCommand("insGroupDet");
dbDet.CommandType = CommandType.StoredProcedure;
dbDet.Transaction = dbTran;
When my code reach on the db.ExecuteNonQuery(dbGroup);
my try block catch an error :
The transaction is either not associated with the current connection or has been completed.
i found many forums with the same issue but there are answer for this question yet.