Birden fazla SQL Server yüklü olan ağlarda aşağıdaki şekilde istediğinize bağlanabilirsiniz.
- Öncelikle Project->Add Referances menü seçenekleri ile açaşağıdaki pencereyi açtırın.
- Bu pencerede COM Yaprağını aktifleştirerek "Microsoft SQLDMO Object Library" seçeneğini projenize dahil edin.
- Son alarak aşağıdaki şekilde bir kodlama kullanabilirsiniz.
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 SQLDMO;//Eklemeyi Unutmayın
namespace SqlOrnek
{
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
SQLDMO.Application Adlar = new SQLDMO.Application();
NameList Liste = Adlar.ListAvailableSQLServers();
for (int i = 0; i <= Liste.Count; i++)
{
try
{
comboBox1.Items.Add(Liste.Item(i));
}
catch { }
}
}
}
}
Nihat DEMİRLİ