Is your firm aware of Integration Manager? It can be used to batch import invoices into the system with all of the checks and balances built in (i.e. duplicate invoices, missing vendors etc.).
I strongly recommend using IM to accomplish this, however I encourage learning so I'll help with the SDK problem.
Going back to the SDK solution, if you noticed, I set the table key to 3 in my previous answer to your other post. There are multiple "keys" per table which can be used and combine different fields as part of the query. Microsoft has explained this here: Table Keys. If you go to the Table Descriptions window in GP, you can find the detailed listing of all keys for each table. Unfortunately I do not have access to a GP installation, but look for a key that contains all the fields you wish to query on. Once you change the key, you simply have to set all the values that the key expects in the table you are performing the query on. Below is an example adding vendor id into the query assuming the key wants the document number and vendorid:
//Search for document number
Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.Key = ### //add key that works for you
Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.DocumentNumber.Value = docNum;
Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.VendorId = vendorID;
TableError err = Microsoft.Dexterity.Applications.Dynamics.Tables.PmPaidTransactionHist.Get();
if (err == TableError.NoError)
{
//Invoice exists
}
else
{
//Invoice does not exist
}
What Sean was mentioning were the actual SQL tables that holds the information in the database and his solution was a SQL query. This can be executed from c#/vb though it is not as simple as using the built-in queries from the SDK as you have to handle the database connection, query and response yourself in your program.
~James