Hi, need help, how to insert into the database based on the last row in CSV. for example, I have 500 lines, all 500 lines already insert into the database. How to do if the row change to the 501 lines and the insert start from line 501. I want to replace it from delete, to insert from line 501. Help me please
- if (LWT > 0)
- {
- Console.WriteLine("There are no changes in lastWriteTime CSV file");
- var del1 = "delete from result";
- var cmd11 = new NpgsqlCommand(del1, conn);
- cmd11.ExecuteNonQuery();
- }
- else
- {
- Console.WriteLine("There are changes lastWriteTime in CSV file");
- var lf2 = "insert into listfile(filename)values(@filename)";
- var cmd3 = new NpgsqlCommand(lf2, conn);
- cmd3.Parameters.AddWithValue("filename", Convert.ToString(file));
- string filename = cmd3.Parameters["@filename"].Value.ToString();
- Console.WriteLine("Record inserted successfully. filename = " + file);
- }