look up the sp_databases stored procedure..
//**
using System.Data;
using System.Data.SqlClient;
private void ListDatabases(string serverName)
{
SqlConnection cn = new SqlConnection("Integrated Security=SSPI;Persist
Security Info=False;User ID=sa;Initial Catalog=te;Data Source=" + serverName
+ ";");
try
{
cn.Open();
SqlDataReader dr = (new SqlCommand("sp_databases",
cn)).ExecuteReader();
}
catch
{
if (cn.State == ConnectionState.Open) {cn.Close();}
return;
}
Console.WriteLine("List of [" + serverName + "] SQL Server" );
while (dr.Read())
{
Console.WriteLine(dr["DATABASE_NAME"] as string);
}
cn.Close();
}
//***
--
Best Regards
Yanick Lefebvre
Reza Alirezaei said:
that works fine,,,how can I get a list of databases available on the
specified server on a separate Combobox?
populated
in