c 23 mysql data reader from two tables

Solutions on MaxInterview for c 23 mysql data reader from two tables by the best coders in the world

showing results for - "c 23 mysql data reader from two tables"
Aarón
18 Apr 2020
1using (SqlConnection connection = new SqlConnection("connection string here"))
2{
3    using (SqlCommand command = new SqlCommand
4           ("SELECT Column1 FROM Table1; SELECT Column2 FROM Table2", connection))
5    {
6        connection.Open(); 
7        using (SqlDataReader reader = command.ExecuteReader())
8        {
9            while (reader.Read())
10            {
11                MessageBox.Show(reader.GetString(0), "Table1.Column1");
12            }
13
14            if(reader.NextResult())
15            {
16               while (reader.Read())
17              {
18                MessageBox.Show(reader.GetString(0), "Table2.Column2");
19              }
20            }
21        }
22    }
23}