Multiple tables from a single DB [modified]
-
There seems to be a problem with my code when I try and retrieve multiple tables. Please tell me what's wrong, or if there is an alternative way to do this? Thanks in advance.
OleDbConnection clsConnection; clsConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\one.mdb;"); clsConnection.Open(); //first table WTest1.oneDataSet f_table = new WTest1.oneDataSet(); OleDbDataAdapter dAdapter = new OleDbDataAdapter("SELECT * FROM first", clsConnection); dAdapter.Fill(f_table, "first"); //second table WTest1.oneDataSet s_table = new WTest1.oneDataSet(); OleDbDataAdapter dAdapter1 = new OleDbDataAdapter("SELECT * FROM second", clsConnection); dAdapter1.Fill(s_table, "second");``Runtime Error: Syntax Error in FROM Clause
--Starmodified on Wednesday, April 29, 2009 1:04 PM
-
There seems to be a problem with my code when I try and retrieve multiple tables. Please tell me what's wrong, or if there is an alternative way to do this? Thanks in advance.
OleDbConnection clsConnection; clsConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\one.mdb;"); clsConnection.Open(); //first table WTest1.oneDataSet f_table = new WTest1.oneDataSet(); OleDbDataAdapter dAdapter = new OleDbDataAdapter("SELECT * FROM first", clsConnection); dAdapter.Fill(f_table, "first"); //second table WTest1.oneDataSet s_table = new WTest1.oneDataSet(); OleDbDataAdapter dAdapter1 = new OleDbDataAdapter("SELECT * FROM second", clsConnection); dAdapter1.Fill(s_table, "second");``Runtime Error: Syntax Error in FROM Clause
--Starmodified on Wednesday, April 29, 2009 1:04 PM
And which is exactly the problem ???
-
And which is exactly the problem ???
-
Why are you using typed datasets? Can you use System.Data.DataSet datasets???
-
Why are you using typed datasets? Can you use System.Data.DataSet datasets???
-
Typed datasets: http://msdn.microsoft.com/en-us/library/esbykkzb(VS.71).aspx[^] http://www.15seconds.com/Issue/031223.htm[^] Normal datasets: declare the connection... create System.Data.Dataset: Dataset ds=new Dataset(); create OledbDataAdapter: OledbDataAdapter adapter=new OleDbDataAdapter("Select * from table1",conn); Fill ds: adapter.fill(ds,"table1"); USe it....