Can anyone tell me how to display the table in windows form application? shall i use datagrid view? and i need to display 6 rows and n number of columns according to the user input
You can refer online sources, there are lot of website having details about creating table in windows form.
Hi, You can check this Code: using System.Data; using System.Data.SqlClient; public partial class Form1 : Form { public Form1() { InitializeComponent(); BindGrid(); } private void BindGrid() { string constring = @"Data Source=.\SQL2005;Initial Catalog=Northwind;User id = sa;password=pass@123"; using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers", con)) { cmd.CommandType = CommandType.Text; using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { using (DataTable dt = new DataTable()) { sda.Fill(dt); dataGridView1.DataSource = dt; } } } } } } Thanks