// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data; using System.Data.SqlClient; class MainClass { public static void Main(string[] args) { SqlConnection con = new SqlConnection("server=DKARNE\\DKARNE;Integrated Security=SSPI;database=master"); con.Open(); SqlCommand cmd = new SqlCommand("sp_databases", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader rdr = cmd.ExecuteReader; while (rdr.Read) { string dbnam = (string)rdr(0); Console.WriteLine("Database=" + dbnam); } con.Close(); } }