0

I am trying to select data from 2 access tables using a single command object. here is my code-

using (OleDbCommand cmdCommand=new OleDbCommand())
{
    cmdCommand.CommandType = CommandType.Text;
    cmdCommand.CommandText = "select * from tableA;select * from tableB";
    cmdCommand.Connection = Connection;
    using (OleDbDataAdapter daData=new OleDbDataAdapter())
    {
       daData.SelectCommand = cmdCommand;
       Connection.Open(); daData.Fill(ds); Connection.Close();
    }
 }

But it throws exception "Characters found after end of sql statement." Any suggesstion?

s.k.paul
  • 7,099
  • 28
  • 93
  • 168
  • use stored procedure or something like that, after the semicolon of first query it wont read anything to be executed – Deepanshu Goyal Apr 09 '13 at 11:45
  • rather create a single query to get data from both tables using joins, because in Access i dont think there are stored procedures to execute multiple queries – Deepanshu Goyal Apr 09 '13 at 11:46

0 Answers0