SqlConnection conn=new SqlConnection();
   conn.ConnectionString=ConfigurationSettings.AppSettings["ConnectionString"];
   string sqlStatement="select * from Orders where
CustomerID=@ID order by OrderID";
   SqlCommand sqlcmd=new SqlCommand(sqlStatement,conn);
   sqlcmd.Parameters.Add("@ID",CustomerID);
   conn.Open();
   
   DataSet ds=new DataSet();
   SqlDataAdapter da=new SqlDataAdapter(sqlcmd);
   da.Fill(ds,"Table");
   this.dg.DataSource=ds;
   this.textBox1.DataBindings.Add("Text",ds,"Table.CustomerID");
 
   try
   {
    SqlDataReader sdr=sqlcmd.ExecuteReader();
    int cols=sdr.FieldCount;
DataTable Mytab=new DataTable();
    Mytab.BeginLoadData();
    for(int i=0;i    {
     Mytab.Columns.Add(sdr.GetName(i),sdr.GetType());
    }
    string [] lvitem=new string[cols];
    object [] values=new object[cols];
    while(sdr.Read())
    {
     DataRow myRow=Mytab.NewRow();
     sdr.GetValues(values);
     for(int i=0;i      myRow[i]=values[i].ToString();
     
     Mytab.Rows.Add(myRow);
    }
    Mytab.EndLoadData();
    this.dg.DataSource=Mytab;
    sdr.Close();
   
   }
   catch(System.Data.SqlClient.SqlException ex)
   {
    MessageBox.Show(ex.Message);
   }
   finally
   {
    conn.Close();
   }