I'm having trouble to figure out how to get more then one SQL query to work in C#. I have something like this:
breakControlq.CommandText =
@"SELECT something as q1 From table" +
"SELECT somethingelse as q2 FROM table where this = this";
breakControlq.CommandType = CommandType.Text;
breakControlq.Connection = hd01Connect;
try
{
hd01Connect.Open();
breakControlRead = breakControlq.ExecuteReader();
while (breakControlRead.Read())
{
textBox1.AppendText(breakControlRead["q1"].ToString());
textBox2.AppendText(breakControlRead["q2"].ToString());
}
catch(System.Data.SqlClient.SqlException ex)
{
MessageBox.Show(ex.Message, "Connection Error");
}
Is this possible to do? Do I have to repeat the connection/command to every single query?
I'm pretty new at this and some of you will tell that this has already been answered somewhere, but I searched so many posts that I'm more confused then when a started to search for the solution.