Running multiple sql queries

Im really new to this and am playing around. I followed this video and was able to query my sql database and get the info I needed. How would i go about adding a second query to this? I tried adding a second gridview to this but keep getting an error (the name gridview2 does not exist in this context. Basically at my job i have a database that when someone has a question i end up having to run several queries against different tables to get all my info. I wanted to write something where i could put in my search string and it will run the queries and spit out all my info.

protected void Button1_Click(object sender, EventArgs e) {

 string str = "select reference, voided from table where (reference like '%' + @search + '%')"; SqlCommand cmd = new SqlCommand(str, db); cmd.Parameters.Add("@search", SqlDbType.NVarChar).Value = TextBox1.Text; db.Open(); cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds, "reference"); GridView1.DataSource = ds; GridView1.DataBind(); db.Close(); } 

by tomtom999 via /r/csharp

Leave a Reply