SQL Server 2008 and NHibernate connection string problem

Discussion in 'Databases' started by tbrooks, Mar 25, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. deployed an ASP.NET MVC with NHibernate application and am attempting to utilize SQL Server 2008. The database has been restored and is there.

    According to the DiscountASP.NET tool, the connection string should be:

    Data Source=tcp:sql2k802.discountasp.net;Initial Catalog=<mydatabase>;User ID=<my user>;Password=<my password>;

    Putting that into the Hibernate.cfg.xml file, I keep getting this error message:
    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"

    I've copied the connection string straight from the control panel, so I don't think that is it. It looks like it is attempting to contact the database via named pipes even though I've specified TCP.

    Any suggestions?
     
  2. HI,
    Have you tried Clear, Remove and Add for the connection name?
    i.e.
    <clear/>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" ...

    Salute,
    Mark
     
  3. With NHibernate, the connection string is stored in a NHibernate specific XML file.

    I was able to get it working, though. Instead of using the connection string supplied by DiscountASP's control panel, I removed the protocol specific declaration and added the protocol's port number:

    Original connection string supplied by DiscountASP's Control Panel:
    Data Source=tcp:sql2k802.discountasp.net,1433;Initial Catalog=...<snipped for brevity>
    The connection string that actually works for me with NHibernate:
    Data Source=sql2k802.discountasp.net,1433;Initial Catalog=....<snipped for brevity>
    Hope this helps anyone who might be having the same issue.
     
  4. Cool...Thanks for posting your solution.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page