I am inserting data from excel to MySQL database. Before inserting it into DB, I want to check if the combination of data (invoicenumber, invoiceamount, and invoicedate) is already present in DB or not. If it is present in DB, the process will not insert that row in DB and insert the rest of the data from excel.
Use Execute Query activity and write a select statement as below
Select * from Table Name where Invoicenumber = ExcelValue AND invoiceamount = ExcelValue and Invoicedate = ExcelValue
Now in the Properties of Datatable->Output to a Datatable
Place a IF Condition and write logic as Datatable.Rows.Count > 0
If it return rows then count will be > 0 i.e., Value already exist in DB else Not available
Hope this helps you
Hi @ksrinu070184, I already tried this solution. But the issue which I am facing with this solution is that it inserts the whole data present in excel into DB in one go and when the user updates any existing data apart from above mentioned three columns(invoicenumber, invoiceamount, invoicedate) and rerun the process, it inserts data in DB which causes duplicate entries in database.
I was trying the below solution.
(From p In xldt.Select()
Where ( From q In opquery.Select() Where String.Join(",",p.ItemArray).equals(String.join(",",q.ItemArray))
But not getting how to implement it for only three columns.