2

I am trying to check if I have already imported data inside my database but I am finding difficulties to do this. Below is my code which I am using in backend, middle layer and front end. Can anyone please check to see what I am doing wrong. Thanks alot for your help.

Mike

This is the backend 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");
                }
            }
3
  • 1
    What problem are you having with this code? Commented Aug 12, 2011 at 6:38
  • i was able to import before adding the code: if (dt.Rows.Count > 0) to check if data is already imported. Commented Aug 12, 2011 at 6:55
  • 1
    I guess you have checked the date is indeed dd/mm/yyyy Commented Aug 12, 2011 at 8:27

1 Answer 1

3

Does your load date contain time ?....if it does you need to truncate your load date to remove it: TRUNC(LOAD_DATE)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.