I am trying to check if I have already imported data in my database, but I find it difficult to do so. Below is my code that I use in the backend, middle tier and front end. Someone can check what I'm doing wrong. Many thanks for your help.
Mike
This is an internal code.
public static Boolean isImported(string date) { DatabaseAdapter dba = DatabaseAdapter.GetInstance(); string sqlQuery = "SELECT * FROM FCR.LOAD_CONTROL " + "WHERE LOAD_DATE = to_date('" + date + "', 'dd/mm/yyyy') "; DataTable dt = new DataTable(); dt.Load(dba.QueryDatabase(sqlQuery)); if (dt.Rows.Count > 0) { return true; } else { return false; } }
This is the business logic code.
public static Boolean isImported(string date) { return DatabaseHandler.isImported(date); }
This is the front end code
if(BusinessLayerHandler.isImported(dateField.Text) == false) { try { BusinessLayerHandler.ImportFromOrion(dateField.Text); Alert("Imported"); } catch (Exception ex) { Alert("Not Imported"); } }
source share