I am working on a project which requires listing of all datasources, connecting them and then fetch the list of tables from them, their columns and later a query builder to query them and fetch the data. The tricky part here is the query Builder and to pass the query and fetch the data directly from the datasources (say oracle , ms sql server, ms access etc)
currently I am fetching all the data(as a dataset or datatable) and parsing them to fetch the output which is not reliable.
Is that possible or a Best approach to achieve this?
Code which I tried.
public DataTable GetDataTableforMSAccess(string strSQL, string Connstr = "")
{
DataTable dt = new DataTable();
try
{
if ((Connstr == null) || (Connstr.ToString() == ""))
{
//Sample connstr "Provider=Microsoft.ACE.OLEDB.12.0;data source=F:\\NWind.accdb";
Connstr = GetDefaultConnectionString();
}
using (OleDbConnection conn = new OleDbConnection(Connstr))
{
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
adapter.Fill(dt);
}
}
catch (Exception ex)
{
LogWrite("GetDataSetforMSAccess :" + ex.Message, true);
}
return dt;
}
Similarly I tried seperately for Oracle , MS SQL, My Sql. I need to merge the queries and run against in a single interface so that I can fetch the desired result.
EDIT: I have fetched the list, the tricky part is i need to query the columns from multiple sources and then run the query which should comprise all the databases required.