Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working with access database I want to select data from two tables as separate result,
So am trying like

VB
Dim query As String = "Select * from Table1;Select * from Table2;"
Using con As New System.Data.OleDb.OleDbConnection(strAccessCon)
   Using accessadp As New System.Data.OleDb.OleDbDataAdapter(query, con)
                    
      Dim ds As New DataSet()
      accessadp.Fill(ds)      

   End Using
End Using


when I execute this code it giving me oledb exception -
Characters found after end of SQL statement.

Any help appreciated..
Thank You

What I have tried:

I tried this with SQL,and its working with SQL
Posted
Updated 10-Oct-16 22:03pm
v2
Comments
Garth J Lancaster 11-Oct-16 2:49am    
if Table1 and Table 2 have the same structure, can you use a 'union' ?
poonam25 11-Oct-16 2:58am    
tbl 1 and tbl 2 have diff structure and data.I wants to fetch data and put into dataset as set of tables
Karthik_Mahalingam 11-Oct-16 4:00am    
use  Reply  button, to post Comments/query to the user, so that the user gets notified and responds to your text.
poonam25 12-Oct-16 13:38pm    
ok..Thanks for updating.

Try two Fill commands:
C#
Dim query As String = "Select * from Table1"
Using con As New System.Data.OleDb.OleDbConnection(strAccessCon)
   Using accessadp As New System.Data.OleDb.OleDbDataAdapter(query, con)
      Dim ds As New DataSet()
      accessadp.Fill(ds, "Table1 Data")
      ds.SelectComamnd.CommandText = "Select * from Table2"
      accessadp.Fill(ds, "Table2 Data")
   End Using
End Using
Two commands in one works in Sql Server, but doesn't in Access.
 
Share this answer
 
Comments
poonam25 12-Oct-16 13:39pm    
Thanks.I solved it in same way.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900