locked
System.Transactions not working with asp.net

    Question

  • Hi,

    I am facing a peculiar problem , I am using Oracle 11g with ODT withODAC1110620.

    I am using system.Transactions to manage a distributed trasaction across two Oracle databases.

    Code works well in windows application , but fails giving Internal data-provider error : -3000 in a asp.net web-application.

    Do I need to enable something for asp.net?

     

    Can someone help please???

    Wednesday, February 06, 2008 8:33 AM

Answers

  •  

    Right, that's for the Oracle problem -- I'm afraid that we can't troubleshoot the Oracle problem from our end since we do not have any configuration knowledge for Oracle, nor do we have the source code to tell you exactly what error -3000 means.

     

    However, you did say you had a similiar issue when using SQL 2k5 instead of Oracle -- I am prepared to help with that issue.  XP SP2 is not sufficiently different than Win2k3 in this instance so that shouldn't matter too much.  Perhaps the same issue that is causing SQL 2k5 to function incorrectly is related to the Oracle issue too.  Would you be able to create a small .aspx page which shows the repro?

    Monday, February 11, 2008 9:06 PM
    Moderator

All replies

  •  

    Perhaps it's because the application is running in low trust.  What is your trust level for the asp.net application -- could you try "Full"?
    Wednesday, February 06, 2008 10:40 PM
    Moderator
  • I tried that using

    <securityPolicy>

    <trustLevel name="Full" policyFile="internal"/>

    </securityPolicy>

     

    But even that did not work  , i have also tried to rum the application in administrator account using impersonation.It seems to be a rights problem only but no god luck yet!

    Thursday, February 07, 2008 5:46 AM
  •  

    The -3000 error code is not from Microsoft.  Are you able to contact Oracle (through their forums perhaps?) to see if they require any sort of ASP.net configuration?   Right now I've been unable to determine what that error code means simply by searching the web.
    Thursday, February 07, 2008 5:52 AM
    Moderator
  • I have even tried with SQL Server 2005 , it gives a transaction aborted error.

    Thursday, February 07, 2008 6:58 AM
  •  

    For the SQL case, can you describe the topology? Is everything running on different machines for instance?

     

    Is there any other piece to the error message besides the transaction abort?  What could be happening is that 1 or more of the machines may not have the correct MSDTC security settings enabled -- if you could post what the MSDTC security settings are for each machine that would help as well.

    Thursday, February 07, 2008 7:48 AM
    Moderator
  •  

    If these settings are not correct , it should not work for desktop applications too , right?

    Anyways  , I have verified the settings as mentioned in various articles.

     

    My question is that , I could not find even any other post similiar to mine , so is it that nobody has tried system.transactions with asp.net?

     

     

    Thursday, February 07, 2008 9:01 AM
  •  

    I do not have direct experience with ASP.net pages but System.Transactions is supported.  The only article I was able to find also mentions permissions problems: http://msdn2.microsoft.com/en-us/library/ms229977.aspx

     

    I'm working on setting up an ASP.net environment to see if I can deduce what the configuration issue is, but that may take some time.

    Friday, February 08, 2008 6:54 PM
    Moderator
  •  

    I'm not able to repro this problem here.  I setup an .aspx page on Win2k3 talking to another SQL 2005 Win2k3 machine.

     

    Inside the Page_Load handler of the .aspx page I created a TransactionScope and opened 2 database connections -- ensuring that MSDTC got involved -- and then committed the transaction.

     

    This page loads fine on Full, High, and Medium trust levels.  On Low I receive the following error:

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

     

     

     

    Monday, February 11, 2008 8:11 AM
    Moderator
  •  

    Well in this case , my machine is XP , and the server machine is Linux
    Monday, February 11, 2008 2:11 PM
  •  

    Right, that's for the Oracle problem -- I'm afraid that we can't troubleshoot the Oracle problem from our end since we do not have any configuration knowledge for Oracle, nor do we have the source code to tell you exactly what error -3000 means.

     

    However, you did say you had a similiar issue when using SQL 2k5 instead of Oracle -- I am prepared to help with that issue.  XP SP2 is not sufficiently different than Win2k3 in this instance so that shouldn't matter too much.  Perhaps the same issue that is causing SQL 2k5 to function incorrectly is related to the Oracle issue too.  Would you be able to create a small .aspx page which shows the repro?

    Monday, February 11, 2008 9:06 PM
    Moderator
  •  

    Please let me know if you're still having issues with this
    Wednesday, February 27, 2008 1:46 AM
    Moderator
  •  

    Yes , I am still having problems with that!
    Wednesday, February 27, 2008 5:34 AM
  •  

    Are you able to isolate the problem when using MS SQL and ASP.net?  I have not been able to reproduce any error here.  If so I will gladly take a look at your .aspx page etc.

     

    For the Oracle error code, were you able to contact Oracle to discover what -3000 means?

    Wednesday, February 27, 2008 5:58 AM
    Moderator
  • Hi,

    The code goes like this

     

    using (TransactionScope scope = new TransactionScope())

    {

    // Create first connection object.

    using (SqlConnection conn1 = new SqlConnection())

    {

    // Set connection string and open the connection. this connection

    // will be automatically enlisted in a distributed transaction.

    conn1.ConnectionString = const1;

    conn1.Open();

    // Create a command to execute the sql statement.

    SqlCommand cmd1 = new SqlCommand();

    cmd1.Connection = conn1;

    cmd1.CommandText = @" INSERT INTO TESTAKSHAY1 VALUES('666')";

     

    // Execute the SQL statement to insert one row in DB.

    //retVal = cmd1.ExecuteNonQuery();

    Console.WriteLine("Rows to be affected by cmd1: {0}", retVal);

    conn1.Close();

    }

     

     

    // Create second connection object.

    using (SqlConnection conn2= new SqlConnection())

    {

    // Set connection string and open the connection. this connection

    // will be automatically enlisted in a distributed transaction.

    conn2.ConnectionString = constr2;

    conn2.Open();

    // Create a command to execute the sql statement.

    SqlCommand cmd1 = new SqlCommand();

    cmd1.Connection = conn2;

    cmd1.CommandText = @" INSERT INTO TESTAKSHAY1 VALUES('666')";

     

    // Execute the SQL statement to insert one row in DB.

    //retVal = cmd1.ExecuteNonQuery();

    Console.WriteLine("Rows to be affected by cmd1: {0}", retVal);

    conn1.Close();

    }

     

    I get an error as soon as I try to open the second connection.....

    Wednesday, February 27, 2008 6:04 AM
  •  

    I tried this across 2 machines -- Machine1 ran the above program and Machine2 was running SQL.  I purposely used incorrect settings to get it to throw exceptions on the second open.  Both SQL connection strings use the same database -- if this isn't the case for you the below will still hold for your third SQL machine.

     

    -- If Machine1's MSDTC's Settings are incorrect: (Network DTC Access is Off  OR  Allow Outbound is Off)

    Unhandled Exception: System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool. ---> System.Runtime.InteropServices.COMException (0x8004D024): The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)

     

    -- If Machine2's MSDTC Settings are incorrect: (Network DTC Access is Off  OR  Allow Inbound is Off)

    Unhandled Exception: System.Transactions.TransactionException: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025) ---> System.Runtime.InteropServices.COMException (0x8004D025): The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)

     

    -- If the Firewall on any machine is incorrect:

    Unhandled Exception: System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.

     

     

    Which error do you see (please provide the full text of the exception including the stack trace)?  Since you are using Console.WriteLine can I assume that this code is running inside a normal (non IIS) process?  Are any of the machines running Windows 2000?

    • Proposed as answer by tuprikov Tuesday, December 23, 2008 7:41 AM
    Wednesday, February 27, 2008 6:03 PM
    Moderator
  • Jesse,
    Short and perfect note! I wish it were an MSDN article.
    Tuesday, December 23, 2008 7:42 AM
  • Thank you so much for this. I never would have guessed that the database server needed to connect back to the webserver just to write something to the database -- but I haven't had to deal with Microsoft server technology for quite some time.
    Tuesday, November 24, 2009 9:02 PM