I've been trying to get different columns from different tables (Access database) into one DataTable. The query / command is correct, but the adapter causes an error
System.Data.OleDb.OleDbException:'Data type mismatch in criteria expression.'
The Command is
SELECT tab_agend.ID, tab_teams.Descricao, tab_agend.idtask
FROM tab_teams
INNER JOIN tab_agend ON tab_teams.ID = tab_agend.idequipa;
It does work on Access but Visual Studio throws an error on the line:
adapter.Fill(dset, "table");
Full code:
string query;
if (Tabela == "tab_agend")
{
query = "SELECT tab_agend.ID, tab_teams.Descricao, tab_agend.idtask " +
" FROM tab_teams " +
" INNER JOIN tab_agend ON tab_teams.ID = tab_agend.idequipa;";
}
else
{
query = "SELECT * FROM " + Tabela;
}
dset.Reset();
adapter = new OleDbDataAdapter(query, connection);
adapter.Fill(dset, "table");