none
how can i publish C# project

    Question

  • hi,

    i have C# application and i am using sql server 2008 for database

    how can i publish the application with database?? i tried publish them and they r working on my computer because i have the server ( sql server) but when i tried to set up on anohter computer it doesn't connect to database because it is not found

    the error message was:

    " A network-related or instance-specific error occured while establishing 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. (provide : Name Pipes Provider, error: 40- could not open a connection to SQL Server"

    Sunday, January 08, 2012 10:09 AM

Answers

  • Hi Heba,

    Welcome to the MSDN forum!

    I'm afraid the connection string is improper in the solution.

    Please see: http://www.connectionstrings.com/sql-server-2008

    Meanwhile, please enable the remote connections as well. 
    See:http://support.microsoft.com/kb/914277

    Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition

    You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:
    1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
    2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
    3. On the Surface Area Configuration for Services and Connections page, expand Database Engine, clickRemote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply

      Note Click OK when you receive the following message:
      Changes to Connection Settings will not take effect until you restart the Database Engine service.
    4. On the Surface Area Configuration for Services and Connections page, expand Database Engine, clickService, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

    Enable the SQL Server Browser service

    If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. For example, SQL Server 2005 Express is installed with a default instance name of <var style="font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 11px; line-height: 17px; text-align: left;">Computer Name</var>\SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps.

    Important These steps may increase your security risk. These steps may also make your computer or your network more vulnerable to attack by malicious users or by malicious software such as viruses. We recommend the process that this article describes to enable programs to operate as they are designed to, or to implement specific program capabilities. Before you make these changes, we recommend that you evaluate the risks that are associated with implementing this process in your particular environment. If you choose to implement this process, take any appropriate additional steps to help protect your system. We recommend that you use this process only if you really require this process.
    1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
    2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
    3. On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, clickAutomatic for Startup type, and then click Apply

      Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows.
    4. Click Start, and then click OK.
    Note When you run the SQL Server Browser service on a computer, the computer displays the instance names and the connection information for each instance of SQL Server that is running on the computer. This risk can be reduced by not enabling the SQL Server Browser service and by connecting to the instance of SQL Server directly through an assigned TCP port. Connecting directly to an instance of SQL Server through a TCP port is beyond the scope of this article. For more information about the SQL Server Browser server and connecting to an instance of SQL Server, see the following topics in SQL Server Books Online:
    • SQL Server Browser Service
    • Connecting to the SQL Server Database Engine
    • Client Network Configuration

    Create exceptions in Windows Firewall

    These steps apply to the version of Windows Firewall that is included in Windows XP Service Pack 2 (SP2) and in Windows Server 2003. If you are using a different firewall system, see your firewall documentation for more information. 

    If you are running a firewall on the computer that is running SQL Server 2005, external connections to SQL Server 2005 will be blocked unless SQL Server 2005 and the SQL Server Browser service can communicate through the firewall. You must create an exception for each instance of SQL Server 2005 that you want to accept remote connections and an exception for the SQL Server Browser service.

    SQL Server 2005 uses an instance ID as part of the path when you install its program files. To create an exception for each instance of SQL Server, you must identify the correct instance ID. To obtain an instance ID, follow these steps:
    1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Configuration Manager.
    2. In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties.
    3. On the SQL Server Browser Properties page, click the Advanced tab, locate the instance ID in the property list, and then click OK.
    To open Windows Firewall, click Start, click Run, type firewall.cpl, and then click OK.

    Create an exception for SQL Server 2005 in Windows Firewall

    To create an exception for SQL Server 2005 in Windows Firewall, follow these steps:
    1. In Windows Firewall, click the Exceptions tab, and then click Add Program.
    2. In the Add a Program window, click Browse.
    3. Click the C:\Program Files\Microsoft SQL Server\<var>MSSQL.1</var>\MSSQL\Binn\sqlservr.exe executable program, click Open, and then click OK

      Note The path may be different depending on where SQL Server 2005 is installed. <var>MSSQL.1</var> is a placeholder for the instance ID that you obtained in step 3 of the previous procedure.
    4. Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception.

    Create an exception for the SQL Server Browser service in Windows Firewall

    To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps:
    1. In Windows Firewall, click the Exceptions tab, and then click Add Program.
    2. In the Add a Program window, click Browse.
    3. Click the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, click Open, and then click OK

      Note The path may be different depending on where SQL Server 2005 is installed.

    Have a nice day!


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 10, 2012 8:24 AM
    Moderator

All replies

  • Hi Heba It Welcomes you to MSDN forums..

    Already discused this problem and got solutions in the following links.

    http://social.msdn.microsoft.com/forums/en-US/sqldataaccess/thread/c488cf76-2515-440f-b3f8-9cfad689c5b6/

     

    Also

    Try This

    GO START -> ALL PROGRAMS -> SQL SERVER 2008/2005/2008 R2
    ->CONFIGURATION TOOLS->
    ->SELECT SQL SERVER CONFIGURATION MANAGER
    ->SELECT SQL SERVER NETWORK CONFIGURATION
    ->SELECT PROTOCOLS FOR MSSQLSERVER(YOUR INSTANT NAME)
    ->IN RIGHT TASK PANEL
    ->MAKE SURE MENTION BELOW:

    DISABLE SHARED MEMORY AND VIA
    ENABLE NAMED PIPE AND TCP/IP

    —-MAKE SAME THING IN
    ->SQL NATIVE CLIENT 10.0(SERVER VERSION) CONFIGURATION – CLIENT PROTOCOLS

    RESTART SQL SERVER(MSSQLSERVER [YOUR INSTANT NAME]) SERVICE


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
    Sunday, January 08, 2012 10:25 AM
  • is this method useful if want to setup the application with database, ignoring connecting to server (server/client)  i mean i need to install it on pc acting as server but without having the management studio sql server

    Sunday, January 08, 2012 10:36 AM
  • You have 2 options:

    1. Buy a remote sql server. You can find very cheap servers. from 5$ per month.

    2. You can use the sql compact edition sql server, which runs on a local pc. But, it means that the DB will be updated only on the client pc.

     

    Noam B. 



    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...
    Sunday, January 08, 2012 10:52 AM
  • Hi Heba,

    Welcome to the MSDN forum!

    I'm afraid the connection string is improper in the solution.

    Please see: http://www.connectionstrings.com/sql-server-2008

    Meanwhile, please enable the remote connections as well. 
    See:http://support.microsoft.com/kb/914277

    Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition

    You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:
    1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
    2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
    3. On the Surface Area Configuration for Services and Connections page, expand Database Engine, clickRemote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply

      Note Click OK when you receive the following message:
      Changes to Connection Settings will not take effect until you restart the Database Engine service.
    4. On the Surface Area Configuration for Services and Connections page, expand Database Engine, clickService, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

    Enable the SQL Server Browser service

    If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. For example, SQL Server 2005 Express is installed with a default instance name of <var style="font-family: 'Segoe UI', Arial, Verdana, Tahoma, sans-serif; font-size: 11px; line-height: 17px; text-align: left;">Computer Name</var>\SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps.

    Important These steps may increase your security risk. These steps may also make your computer or your network more vulnerable to attack by malicious users or by malicious software such as viruses. We recommend the process that this article describes to enable programs to operate as they are designed to, or to implement specific program capabilities. Before you make these changes, we recommend that you evaluate the risks that are associated with implementing this process in your particular environment. If you choose to implement this process, take any appropriate additional steps to help protect your system. We recommend that you use this process only if you really require this process.
    1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
    2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
    3. On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, clickAutomatic for Startup type, and then click Apply

      Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows.
    4. Click Start, and then click OK.
    Note When you run the SQL Server Browser service on a computer, the computer displays the instance names and the connection information for each instance of SQL Server that is running on the computer. This risk can be reduced by not enabling the SQL Server Browser service and by connecting to the instance of SQL Server directly through an assigned TCP port. Connecting directly to an instance of SQL Server through a TCP port is beyond the scope of this article. For more information about the SQL Server Browser server and connecting to an instance of SQL Server, see the following topics in SQL Server Books Online:
    • SQL Server Browser Service
    • Connecting to the SQL Server Database Engine
    • Client Network Configuration

    Create exceptions in Windows Firewall

    These steps apply to the version of Windows Firewall that is included in Windows XP Service Pack 2 (SP2) and in Windows Server 2003. If you are using a different firewall system, see your firewall documentation for more information. 

    If you are running a firewall on the computer that is running SQL Server 2005, external connections to SQL Server 2005 will be blocked unless SQL Server 2005 and the SQL Server Browser service can communicate through the firewall. You must create an exception for each instance of SQL Server 2005 that you want to accept remote connections and an exception for the SQL Server Browser service.

    SQL Server 2005 uses an instance ID as part of the path when you install its program files. To create an exception for each instance of SQL Server, you must identify the correct instance ID. To obtain an instance ID, follow these steps:
    1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Configuration Manager.
    2. In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties.
    3. On the SQL Server Browser Properties page, click the Advanced tab, locate the instance ID in the property list, and then click OK.
    To open Windows Firewall, click Start, click Run, type firewall.cpl, and then click OK.

    Create an exception for SQL Server 2005 in Windows Firewall

    To create an exception for SQL Server 2005 in Windows Firewall, follow these steps:
    1. In Windows Firewall, click the Exceptions tab, and then click Add Program.
    2. In the Add a Program window, click Browse.
    3. Click the C:\Program Files\Microsoft SQL Server\<var>MSSQL.1</var>\MSSQL\Binn\sqlservr.exe executable program, click Open, and then click OK

      Note The path may be different depending on where SQL Server 2005 is installed. <var>MSSQL.1</var> is a placeholder for the instance ID that you obtained in step 3 of the previous procedure.
    4. Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception.

    Create an exception for the SQL Server Browser service in Windows Firewall

    To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps:
    1. In Windows Firewall, click the Exceptions tab, and then click Add Program.
    2. In the Add a Program window, click Browse.
    3. Click the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, click Open, and then click OK

      Note The path may be different depending on where SQL Server 2005 is installed.

    Have a nice day!


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 10, 2012 8:24 AM
    Moderator
  • Hi Heba,

    I temporarily mark my reply as an answer to push the case forward. You can unmark it if it provides no help.

    Thank you for your understanding and have a nice day!

    yoyo


    Yoyo Jiang[MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, January 18, 2012 6:12 AM
    Moderator