{
string connstr = "server=.;initial catalog=maa;uid=mah;pwd=mah";
SqlConnection con = new SqlConnection(connstr);
con.Open();
DataSet mydatasett;
string dgv = " select srno,particulars,carats,rate,debit from depurchaseA";
SqlCommand dgvcmd = new SqlCommand(dgv, con);
SqlDataAdapter dgvdap = new SqlDataAdapter(dgvcmd);
mydatasett = new DataSet();
dgvdap.Fill(mydatasett);
bindingsource2 = new BindingSource();
bindingsource2.DataSource = mydatasett;
bindingsource2.DataMember = mydatasett.Tables[0].TableName;
dataGridView1.DataSource = bindingsource2;
}