First of all you have to create a table in a database for this you have to do following things:
1 goto Project then click on Add Components. In Add New Item you have to click Service-based Database .
2. In Server Explorer you have to add a new table with data by clicking Tables under Data Connection.
3. when you add the table and data in a table you have to write these code in a button click.
private void button1_Click(object sender, EventArgs e)
SqlConnection sc = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True");
SqlDataAdapter sd = new SqlDataAdapter("select * from customers", sc);
DataSet ds = new DataSet();
dataGridView1.DataSource = ds.Tables;
In this code my table is customers.