Thursday, 16 February 2012

to display table on DataGrid


private void BtnDisplay_Click(object sender, EventArgs e)
        {
            string str = string.Empty;
            str = "select * from <Table Name>";
            conn.Open();
            SqlDataAdapter da = new SqlDataAdapter(str,conn);
            da.Fill(ds);
            GdvDisplay.DataSource = ds.Tables[0];
            conn.Close();
        }

No comments:

Post a Comment