Good morning Guys,

I've got this code currently running:

        private void button1_Click(object sender, EventArgs e)
        {
            SqlDataSourceEnumerator sdse = SqlDataSourceEnumerator.Instance;
            DataTable table = sdse.GetDataSources();
            foreach (DataRow row in table.Rows)
            {
                instanceCombobox.Items.Add(row["ServerName"].ToString() + "\\" + row["InstanceName"].ToString());
            }

Which gives me the Instance and Name of the SQL Server over the Network.

I'm now looking to Cycle through available databases on the 'Selected' Instance. Ideally the Databases for the 'Selected' Instance in the 'Top Combo Box' would be in a seperate 'ComboBox.

I checked the Databale through debug but the information is not held there so cannot call it.

Any help would be great.

Regards
Mark.

You'll need to connect to the selected instance and run the sp_databases stored procedure (assuming you have the priviliges to do so).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.