Search
 
SCRIPT & CODE EXAMPLE
 

SQL

C# mysql data reader from two tables

using (SqlConnection connection = new SqlConnection("connection string here"))
{
    using (SqlCommand command = new SqlCommand
           ("SELECT Column1 FROM Table1; SELECT Column2 FROM Table2", connection))
    {
        connection.Open(); 
        using (SqlDataReader reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                MessageBox.Show(reader.GetString(0), "Table1.Column1");
            }

            if(reader.NextResult())
            {
               while (reader.Read())
              {
                MessageBox.Show(reader.GetString(0), "Table2.Column2");
              }
            }
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Sql :: like query 
Sql :: sql if function 
Sql :: sql limit order by 
Sql :: what is denormalization in sql 
Sql :: while in sql server 
Sql :: ORACLE sql join multiple tables 
Sql :: insert data from one database table to another database table in postgresql using pgadmin 
Sql :: pgadmin postgres ERROR: database is being accessed by other users 
Sql :: sql table 
Sql :: insert or update sql query 
Sql :: SQL Syntax of INNER JOIN 
Sql :: dump sql file to database postgres 
Sql :: set engine to innodb 
Sql :: mysql custom sort order 
Sql :: openquery join two tables 
Sql :: hour must be between 1 and 12 
Sql :: logical operators in sql 
Sql :: how to get second highest salary in each department in sql 
Sql :: selecting specific day in colum sql 
Sql :: excel vba import data to sql server 
Sql :: insert json file to mssql 
Sql :: get string between specific character sql 
Sql :: import mysql command line 
Sql :: identify rows with 2 same column value and delete duplicate mysql 
Sql :: mysql stored procedure insert if not exists 
Sql :: sql searching via key word 
Sql :: What is SQL data store? 
Sql :: what is primary key 
Sql :: trigger in mysql 
Sql :: grant sql 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =