Hasibul Kamel

Hasibul Kamel

  • NA
  • 44
  • 4.2k

new records added in csv

Sep 2 2020 1:39 AM
Hi, I need help on how to update to the database if there are new records added in CSV file.
 
If only 3 new records added in the CSV file, only insert those 3 new records, not all records.
  1. if (LWT > 0)  
  2. {  
  3.     Console.WriteLine("There are no changes in lastWriteTime CSV file");  
  4. }  
  5. else  
  6. {  
  7.     Console.WriteLine("There are changes lastWriteTime in CSV file");  
  8.     var lf2 = "insert into   
  9.     listfile(filename,lastwritetime)values(@filename,@lastwritetime)";  
  10.     var cmd3 = new NpgsqlCommand(lf2, conn);  
  11.     cmd3.Parameters.AddWithValue("filename", Convert.ToString(file));  
  12.     string filename = cmd3.Parameters["@filename"].Value.ToString();  
  13.     Console.WriteLine("Record inserted successfully. filename = " + file);  
  14. }  

Answers (1)