Im trying to understand how to fill a GridView1 control with the values from my query.
I know how to connect to the dB, but dont know how to fill the grid. Can someone show me how to do this? Below is the code i have.
Thanks for any help
protected void Button1_Click(object sender, EventArgs e)
SqlConnection sqlConnection1 = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\ConDb.mdf;Integrated Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT nameID, Fname FROM name WHERE (Fname = 'mike')";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
// open connetction
need data adapter and data set
// close connection