Problem using multiple joins using Oledb (viual studio, c#) to connect to Paradox

Asked

Viewed 25 times

0

I am working with a legacy code using the Paradox database. In one part of it there is a query already implemented and working:

string FUNCAUXatr= @"TA.bdTEMDEFICIENCIA,TA.bdDEFVISUAL,TA.bdDEFFISICA, 
                     TA.bdDEFAUDITIVA,TA.bdDEFMENTAL,TA.bdDEFINTELECTUAL,
                     TA.bdREABILITADO,TA.bdCOTADEF, TA.bdESTADOCIVIL,TA.bdGRAUINSTRUCAO,
                     TA.bdUFCNH,TA.bdPRIHAB";

string command = $@"select TF.*, {FUNCAUXatr}
    from TFUNCION as TF
    inner join TFUNCAUX as TA
        ON TA.bdCODIGO = TF.bdCODIGO AND TA.bdCODEMP = TF.bdCODEMP
    where TF.bdCODEMP in ({selectedList})";
    
[...]

OleDbDataReader r = command.ExecuteReader();
while(r.Read){...}

Now I’m trying to make a Join with the TFUNCESOC table:

string comand = $@"select tf.*, {FUNCAUXatr}, tfe.bdCONJUGEBRASIL
    from TFUNCION as tf
    inner join TFUNCAUX as ta
        ON ta.bdCODIGO = tf.bdCODIGO AND ta.bdCODEMP = tf.bdCODEMP
    inner join TFUNCESOC as tfe
        ON tfe.bdCODIGO = tf.bdCODIGO AND tfe.bdCODEMP = tf.bdCODEMP
    where tf.bdCODEMP in ({selectedList})";

and the program for with the exception:
System.Data.OleDb.OleDbException (0x80040E14): Erro de sintaxe (operador faltando) na expressão de consulta ''

  • This is Sopt, please translate your question or ask in the American OS

1 answer

0

I solved the problem by parenting around the first Join (according to this answer https://stackoverflow.com/questions/35305904/paradox-db-sql-multiple-joins)

the final consultation was

string command = $@"select TF.*, {FUNCAUXatr}, TFE.bdCONJUGEBRASIL
                   from (TFUNCION as TF
                   inner join TFUNCAUX as TA
                       ON TA.bdCODIGO = TF.bdCODIGO AND TA.bdCODEMP = TF.bdCODEMP)
                   inner join TFUNCESOC as TFE
                       ON TFE.bdCODEMP = TF.bdCODEMP AND TFE.bdCODIGO = TF.bdCODIGO 
                   where TF.bdCODEMP in ({selectedList})";

:)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.