The problem is arising as you are using an object with out making new object(ie with new key word)
Try This or compare it with your code
SqlConnection con=new SqlConnection(
con.Open();
SqlCommand cmd=new SqlCommand();
DataSet ds=new DataSet();
cmd.CommandText="select * from table";
cmd.Connection=con;
SqlDataAdapter ad=new SqlDataAdapter();
ad.Fill(ds);
Gridview.DataSource=ds.Tables[0];
GridView.Databind();