h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Get SQL Server Name in C#.net

Today we will discuss about Get SQL Server Name in C#.net
Get SQL Server Name:
 Add Three References in your Project
·         Microsoft .SqlServer.ConnectionInfo
·         Microsoft .SqlServer.management.Sdk.sfc
·         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;