GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Microsoft  >  Ado.NET

 Print  |  
Question:  retrieve two tables of data at a time by using data reader

Answer: One interview I faced a Q:
how can i retrieve two tables of data at a time by using data reader?
Data reader read and forward only, how is it possible to get 2 tables of data at a time


December 12, 2007 09:51:14 #4
 wrijub   Member Since: November 2006    Total Comments: 4 

RE: retrieve two tables of data at a time by using data reader
 
For the following code

----------------------------------------
objCmd.CommandText = "SELECT * FROM [Categories];SELECT * FROM [Customers];";
objRdr = objCmd.ExecuteReader();
----------------------------------------


It Keeps throwing the following exception
-----------------------
System.Data.OleDb.OleDbException: Characters found after end of SQL statement.
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.OleDb.OleDbCommand.ExecuteReader()
-----------------------

Now what to do?????
     

 

Back To Question