Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:51:47+00:00 2026-06-01T12:51:47+00:00

I have this code in Transaction.cs using (TransactionScope scope = new TransactionScope()) { //

  • 0

I have this code in Transaction.cs

using (TransactionScope scope = new TransactionScope())
{
        // Setup nhibernate configuration
        Configuration config = new Configuration();            
        config.SetProperty("hibernate.connection.connection_string", GlobalVar.TRUECONNSTRING);
        config.SetProperty("hibernate.command_timeout", "3600");
        config.AddAssembly(typeof(ProductionMovein).Assembly);

        // Setup nhibernate session
        ISessionFactory factory = config.BuildSessionFactory();
        ISession session = factory.OpenSession();
        ITransaction transaction = session.BeginTransaction();

        //Recalculate Number
        PairData pairCabang = (PairData)comboCabang.SelectedItem;
        textNo.Text = FormFunction.getNumber(2, pairCabang.key, dtpTanggal.Value);

        // Insert data
        try
        {
            //ProductionMoveIn
            ProductionMovein productionMoveIn = new ProductionMovein();
            productionMoveIn.Nomor = textNo.Text;
            session.Save(productionMoveIn);    

            transaction.Commit();
            session.Close();
        }
        catch (Exception ex)
        {
            transaction.Rollback();
            session.Close();
            MessageBox.Show(ex.InnerException.Message);
            return 1;
        }

    scope.Complete();
}

And the error is started from

textNo.Text = FormFunction.getNumber(2, pairCabang.key,
dtpTanggal.Value);

i have this code in Formfunction.cs

public static string getNumber(int formID, int cabangID, DateTime date)
{
    string formNumber = "";
    string strQuery = "";

        formNumber += formNames[formID, 0] + "/" + + date.ToString("yy") + date.ToString("MM") + "/";

    // Setup nhibernate configuration
    NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();        
        config.SetProperty("hibernate.connection.connection_string", GlobalVar.TRUECONNSTRING);
        config.SetProperty("hibernate.command_timeout", "3600");
    config.AddAssembly(typeof(Login).Assembly);

    //// Setup nhibernate session
    ISessionFactory factory = config.BuildSessionFactory();
    ISession session = factory.OpenSession();

            strQuery = "SELECT MAX(REVERSE(SUBSTRING(REVERSE(a.Nomor), 1, 5))) as 'latest' FROM " + formNames[formID, 1] +
                   " a WHERE a.cabang = " + cabangID +
                   " AND YEAR(a.tanggal) = '" + date.ToString("yyyy");

    Object result = session.CreateSQLQuery(strQuery)
        .AddScalar("latest", NHibernateUtil.Int32)
        .UniqueResult();
    session.Close();

    int nRow;
    if (result == null)
        nRow = 0;
    else
        nRow = (int)result;
    formNumber += (nRow + 1).ToString("d5");

    return formNumber;
}

I have tried to change the Server to 10.10.7.10 (my ip) and it works. but, when i change to other ip, it cannot open connection.
I have tried to turn on msdtc on my computer and the other server i tried to connect, but still get the same error.
enter image description here

enter image description here

Can anybody help me how to solve this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:51:48+00:00Added an answer on June 1, 2026 at 12:51 pm

    Which database are you using? (I’ve assumed MS SQL)
    Can you post the exception detail please?

    Here’s an approach.

    1. First comment out the using (TransactionScope) / scope.Complete
      and try connect to the remote database – i.e. to ensure that your
      local Sql client is configured for TCP/IP, the remote server allows
      remote TCP/IP connections (usually port 1433), and that your login
      credentials and access are correct.
    2. DTC is usually only required when 2 or more connections are used. If
      you reinstate the TransactionScope, but then remove the NHibernate
      transaction, then DTC might not be required at all. Also note that
      TransactionScopes default to Read Serializable isolation –
      TransactionScope functions
    3. Ensure that DTC is configured on both your PC and the Server to
      allow remote connections etc – picture.

      You also need to tackle firewall issues
      DTC firewall requirements?

    EDIT

    By default, SQL Express isn’t open to remote connections – on the remote server, you will need to enable TCP/IP on SQL Configuration Manager, open up the firewall for 1433 / 1434, and as @Özgür mentions, ensure that the SQL the browser service is running (or change your instance name, or change your connection string to use ip, port). More on this here : http://www.sevenforums.com/system-security/58817-remote-access-sql-server-express-2008-windows-7-a.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code like this: try { using (TransactionScope scope = new TransactionScope())
I have this following code:- using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required)) { bool IsCreated=false;
I have this code to show a map using the Virtual Earth API: <script
I have a block of code that runs within a TransactionScope and within this
I have the following code in my application: using (var database = new Database())
I am using suds client for WSDL in our project. i have this code
I have 2 mappings like this: <hibernate-mapping> <class name=A table=A> <id name=code column=aCode type=integer>
Guys I have this peace of code I'm using phonegap with jqueryMobile to develop
i have this code: function getData(){ db.transaction(function(tx){ tx.executeSql('SELECT * from q', [], function(tx, result){
I have some code which is doing this: String transactionId = incoming.getJMSCorrelationID(); when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.