none
How do I find the server name?

    Question

  • I need to deploy a multi-user application to several different customers.  My app was built on VB.net and uses SQL Server Express.  For remote client to connect to the server I understand that I need to use a connection string something like this:
    “Server=ServerName;Database=myDB;Trusted_Connection=True;”

    My question is, how will I know what the server name is?  Can that be different for different customers?  When I test this on my PC, I use (Server=.\SQLEXPRESS;), but what do I use for deployment?

    Thanks.

     

    Tuesday, August 01, 2006 7:17 PM

Answers

  • hi,

    for each "remote" client, you have to store (on each client) the server instance name they are pointing to...

    if I have to connect form my machine to your SQLExpress instance, I should connect to YourMachineName\SQLExpress, as you installed a named instance...

    you can perhaps have a look at http://www.sqldev.net/misc.htm for 3 different way to enlist SQL Server instances on the lan...

    regards

    Tuesday, August 01, 2006 7:59 PM

All replies

  • hi,

    for each "remote" client, you have to store (on each client) the server instance name they are pointing to...

    if I have to connect form my machine to your SQLExpress instance, I should connect to YourMachineName\SQLExpress, as you installed a named instance...

    you can perhaps have a look at http://www.sqldev.net/misc.htm for 3 different way to enlist SQL Server instances on the lan...

    regards

    Tuesday, August 01, 2006 7:59 PM
  • Thank you Andrea for your response.  I would like to make the installation an automated process using InstallShield.  I will have two install packages - one for Server and the other for Clients.  How can I find the ServerName during the client install? 

    P.S: I was trying to locate a relevant article/info at the site you mentioned, but could not find any.  I would appreciate it if you can point me to a specific article.

    Wednesday, August 02, 2006 11:43 PM
  • hi,

    unfortunately, usually you can't...

    say you install the "clients" before SQL Server ()... how can you tell what the server name is?

    you can perhaps, in your InstallShield code, try instantiating a SQL-DMO.SQLServer object to perform a network scan of installed instances, but this will fail if SQL-DMO has not been already locally installed on the client workstation..

    but you can find "smart" solutions.. you can define a share where all your client will point to in order to read some "config" file where they can find the SQL Server they will connect to, but you are there again.. how can you define the network share your app should look for at install time?

    so just provide, in your client application, a tool\dialog to define the server name.. at very first startup it could be void and the dialog can automatically pop up, so that the user can finally "browse for installed SQL Server instances" the way you like or is just required to type it's name as the local admin already reported him by internal mail

    regards

     

    Thursday, August 03, 2006 12:19 AM
  • Thank you for your reply.  I have written below what I am thinking as to how I may go about it.  Please review and let me know if you have suggestions or comments.

    On the install CD, there will be only a Server Install package.  During the server installation, it creates a "Client Install" folder and copies Client Install files to that folder.  Also it creates a text file called "ServerName.txt" in the same folder and writes the Server's Computer name on it. 

    To install a client, from the client machine user needs to access the folder on the server and run install.  The Client install process reads the Server Computer Name and creates a registry entry on the client.

    My application, when run, it reads the "Server's Computer Name" from the registry and coins the connection string and connects to the server.

    Please let me know if I can make this process more efficient.

    Thanks.

     

    Thursday, August 03, 2006 1:22 AM
  • hi,

    yes, this can be a "smart" solution...

    regards

    Thursday, August 03, 2006 12:48 PM