using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;


namespace DatabaseList
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            databaseList.Items.Clear();
            Server server = new Server(serverName.Text);
            server.ConnectionContext.NonPooledConnection = true;
            foreach (Database database in server.Databases)
            {
                databaseList.Items.Add(database.Name);
            }
            server.ConnectionContext.SqlConnectionObject.Close();          
        }
    }
}