public kv3() { InitializeComponent(); db = new KvadroEntities6(); var data = from r in db.CustomerInfo select r; kvadroGrid.ItemsSource = data.ToList(); //var ConnectionString = @"Data Source=SERGEY-PC;Initial Catalog=Kvadro;Integrated Security=True"; //using (SqlConnection con = new SqlConnection(ConnectionString)) //{ // SqlCommand com = new SqlCommand("SELECT * FROM CustomerInfo", con); // con.Open(); // SqlDataReader reader; // reader = com.ExecuteReader(); // while (reader.Read()) // { // try // { // string result = reader.GetString(4); // ComboINN.Items.Add(result); // ComboINN.Text = result; // } // catch { } // } // con.Close(); //} }
public kv2() { InitializeComponent(); //DataContext = this; //ObjectQuery<ProjectInfo> products = db.ProjectInfos; //var query = //from product in products //select new { product.Name, product.Color, CategoryName = product.ProductCategory.Name, product.ListPrice }; //kvadroGrid.ItemsSource = query.ToList(); // kvadroGrid.ItemsSource = db.ProjectInfos.Local.ToList(); //this.Closing += MyWindow_Closing; //db.ProjectInfos.Load(); db = new KvadroEntities6(); var data = from r in db.ProjectInfo select r; kvadroGrid.ItemsSource = data.ToList(); var ConnectionString = @"Data Source=SERGEY-PC;Initial Catalog=Kvadro;Integrated Security=True"; using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand com = new SqlCommand("SELECT * FROM CustomerInfo", con); con.Open(); SqlDataReader reader; reader = com.ExecuteReader(); while (reader.Read()) { try { string result = reader.GetString(4); ComboINN.Items.Add(result); ComboINN.Text = result; } catch { } } con.Close(); } }