Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i am creating a application remote sqlserver database backup
so how can i get all sqlserver name from network in c#

i am using this code
but i am only geting local system name and instance name but from network i am geting only servername not instance name so i am not able to connect to network server i have allow remoteconnection and service automatily also restart.

C#
SqlDataSourceEnumerator SqlEnumerator;
           SqlEnumerator = SqlDataSourceEnumerator.Instance;
           DataTable dTable = SmoApplication.EnumAvailableSqlServers(false);

           DataTable dTable = SqlEnumerator.GetDataSources();

           foreach (DataRow db in dTable.Rows)
           {
               comboBox1.Items.Add(db["ServerName"].ToString()+ "\\" + db["InstanceName"].ToString());
           }
Posted
Updated 9-Jul-11 2:16am
v2

I'm not sure what causes this but I have seen this issue first-hand. Have you actually tried connecting using ONLY the server name without the instance name. I wrote an application which is used at my job. A combobox is used to display the available SQL Server instances on the network. While practically everyone sees "SERVER\INSTANCE", there is one computer which only displays the server name for all SQL Servers on the network. However, if that computer's user chooses to Connect it will connect properly. Strange.
 
Share this answer
 
This article suggests its possible to call an SP and return the name;
http://sqldbpool.com/2008/09/03/how-to-change-sql-server-instance-name/[^]

Unconfirmed though........give it a try and feedback here :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900