Hello everyone .
I have wrote a code which is reading Text Files and save them in a list after that import this list into DB so far it's fine the problem is i have until now 400 text fiels each text fiel has around 300000 until 500000 line and each time want to import a new text flel it will reinsert or reimport the text files which are already imported . that's meaing my data will be always duplicated.
so how could i check with C# code if this text files is already imported or exist in DB ?!
here is some code to be more clear :
- private static List
GetWebShopDataAccesses( string path) - {
- List
elements = new List - List<string> lines = File.ReadAllLines(path).ToList();
- return elements;
- // here i am gettng the list back then import this list into DB during an extensions method with sqlbulk
- }
- private static void ImportToDB()
- {
- string CS =""
- using (SqlConnection connection = new SqlConnection(CS))
- {
- SqlBulkCopy bulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock | SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.UseInternalTransaction, null);
- bulkCopy.DestinationTableName = "TestWebShop";
- connection.Open();
- bulkCopy.WriteToServer(GetListOfWebShop.AsDataTable());
- }
- }
Rajanikant HawaldarPosted Jan 10, 2020, 3:56 AM
Laxmidhar SahooPosted Jan 11, 2020, 12:15 AM
Laxmidhar SahooPosted Jan 9, 2020, 11:47 PM