using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.Sql;
using Microsoft.Win32;
//using Microsoft.SqlServer.Management.Smo;
namespace DataSearchinginDB
{
public partial class frmDataSearching : Form
{
public frmDataSearching()
{
InitializeComponent();
}
private void frmDataSearching_Load(object sender, EventArgs e)
{
SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
System.Data.DataTable table = instance.GetDataSources();
foreach (System.Data.DataRow row in table.Rows)
{
if (row["ServerName"] != DBNull.Value && Environment.MachineName.Equals(row["ServerName"].ToString()))
{
string item = string.Empty;
item = row["ServerName"].ToString();
if (row["InstanceName"] != DBNull.Value || !string.IsNullOrEmpty(Convert.ToString(row["InstanceName"]).Trim()))
{
item += @"\" + Convert.ToString(row["InstanceName"]).Trim();
}
cmbServer.Items.Add(item);
}
}
}
}
}
I coded it in C# for load server name. But now I need to load database name with out any connection. Please help me to do this..