using System; using System.Data.SqlClient; using System.Configuration; class Baasiproov1{ public static void Main(string[] arg){ string constr=@"Data Source=capellaop\sqlexpress;Initial Catalog=baas1;Integrated Security=True"; //string constr=@"Data Source=capellaop\sqlexpress;Integrated Security=false;User ID=kasutaja1;Password=kasutaja1"; //SqlClientPermission perm=new SqlClientPermission(PermissionState.None); //perm.Add(constr, KeyRestrictionBehaviour.AllowOnly); // string constr="Data Source=localhost\\SQLEXPRESS;"+ // "Initial Catalog=baas1; "+ // "Integrated Security=SSPI; Persist Security Info=False"; Console.WriteLine(ConfigurationManager.ConnectionStrings["DatabaseConnection"].ConnectionString ); string lause="SELECT eesnimi FROM inimesed"; SqlConnection cn=new SqlConnection(constr); cn.Open(); SqlCommand cm = new SqlCommand(lause, cn); SqlDataReader reader=cm.ExecuteReader(); while(reader.Read()){ Console.WriteLine(reader.GetString(0)); } cn.Close(); } } /* D:\kodu\0606\dotnet>Baasiproov1 Juku Mati Sass */