.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get SQL Server Name in C#.net

Posted By:Narayanan       Posted Date: April 12, 2013    Points: 40    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

Today we will discuss about Get SQL Server Name in C#.net
 

Get SQL Server Name:

 Add Three References in your Project

 1)      Microsoft .SqlServer.ConnectionInfo

2)      Microsoft .SqlServer.management.Sdk.sfc

3)      Microsoft .SqlServer.Smo



Declare namespace:
using Microsoft.SqlServer.Management.Smo;

Drag and Drop ComboBox in your form.

             DataTable dataTable1 = SmoApplication.EnumAvailableSqlServers(false);
            cmbServerName1.ValueMember = "Name";
            cmbServerName1.DataSource = dataTable1;



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend