public void select_orders(String CustID) { string connectionString = @"Server=localConn; Initial Catalog=Northwind; Integrated Security=True"; using (SqlConnection conn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("SELECT_ORDERS", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@CustomerID", CustID)); conn.Open();
//Fill The DataTable From Command SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt);
//Set It To Binding Navigator BindingSource itmBindSource = new BindingSource(); itmBindSource.DataSource = dt; itmBindNavigator.BindingSource = itmBindSource; itmBindNavigator.Dock = DockStyle.Bottom;
TextBox temp_checked = new TextBox(); temp_checked.DataBindings.Add("Text", itmBindSource, "ShipPostalCode"); if (temp_checked.Text != null) checkBox1.CheckState = System.Windows.Forms.CheckState.Checked; else checkBox1.CheckState = System.Windows.Forms.CheckState.Unchecked;
custID_txt.DataBindings.Add("Text", itmBindSource, "CustomerID"); shipRegion_combo.DataBindings.Add("SelectedValue", itmBindSource, "ShipRegion"); freight_txt.DataBindings.Add("Text", itmBindSource, "Freight"); orderID_txt.DataBindings.Add("Text", itmBindSource, "OrderID");
} }
|