Q:

MySQL insert based on datetime

This is my first post ever, so I apologize if I unknowingly break any rules regarding post etiquette.  
I am migrating db entries using C# and the Redmine API.  I need to pull the time entries in XML and insert into MySQL if and only if the time entries are newer than what exists currently in the database.
Right now I am prototyping this by simply rerouting the original MySQL db entries back to MySQL and into a new table.  Later I will using ERP software similar to SAP software.
I am not sure if the program logic needs to be primarily in the C# code, or in a MySQL statement.  Here is where I am stuck:
foreach (TimeEntry t in timeEntries.list)
{

   comm.CommandText =
     "INSERT INTO time_entries(time_entry_id,project_id,issue_id,user_id,activity_id,hours,comments,"
     + "spent_on,created_on,updated_on,customer_number)"
     + "VALUES(?time_entry_id,?project_id,?issue_id,?user_id,?activity_id,?hours,?comments,?spent_on,"
     + "?created_on,?updated_on,?customer_number)";
     comm.Parameters.AddWithValue("?time_entry_id", t.id);
     comm.Parameters.AddWithValue("?project_id", t.project.Id);
     comm.Parameters.AddWithValue("?issue_id", t.issue.id);
     comm.Parameters.AddWithValue("?user_id", t.user.id);
     comm.Parameters.AddWithValue("?activity_id", t.activity.id);
     comm.Parameters.AddWithValue("?hours", t.hours);
     comm.Parameters.AddWithValue("?comments", t.comments);
     comm.Parameters.AddWithValue("?spent_on", t.spent_on);
     comm.Parameters.AddWithValue("?created_on", t.created_on);
     comm.Parameters.AddWithValue("?updated_on", t.updated_on);
     comm.Parameters.AddWithValue("?customer_number", t.custom_fields.list[0].value);

     comm.ExecuteNonQuery();
     comm.Parameters.Clear();  
     continue; 
}

Of course, everything inserts just fine, and subsequent runs of the program will simply insert duplicate records.  When this is finished, the idea is that it will run as a daily cron job that will update MySQL with new time entries only.
As I mentioned, at a later point I will be sending the XML data directly to an ERP program similar to SAP software, but right now I want to make sure the MySQL to MySQL prototype works first.
I am a relatively new programmer, and a first time poster, so if there are flaws with my code logic or if my question is not specific enough then please let me know.  Thanks in advance.

A:

Actually, I just figured out a working solution.  Not sure if it is the best way to do it, but it works, so I am happy.
All I did was changed updated_on to be the primary key in MySQL, and then handled the exception that was thrown for duplicate entries:
try
                {
                    comm.ExecuteNonQuery();

                }
                catch(MySql.Data.MySqlClient.MySqlException mySqlEx)
                {
                    Console.WriteLine("Duplicate entry found");
                }  

I wanted to post the code in case it helps anyone else searching for an answer to this same issue.  As far as I am concerned, this problem is now solved.

