I would like to know what are the best way to import EXCEL/CSV/TXT file into MySQL using c#.net Desktop app.
Thanks in advance ..
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Imtiyaz AnsariRank #1,031 · 1.9K reputationPosted Mar 18, 2013, 10:36 AM EDT
Microsoft.Office.Interop.Excel.dll
gridview data create excel file :-
TulasiRank #2,544 · 549 reputationPosted Mar 18, 2013, 9:19 PM EDT
But my question is howto import excel/csv/txt data into MySql ?
i possible way is Using LOAD DATA INFILE query .
is there any other alternative and better approach to insert data into mysql?
Candy Brown24 reputationPosted Dec 2, 2014, 11:50 PM EST
There are couple of ways you can do this. Although Imtiyaz's code does not show it, you can use an excel automation in .NET in order to create a DataTable object from the existing excel file, but this can be a rather slow approach and also it will require a MS Excel installed on the machine.
A faster approach would be to use OLEDB for this.
But yes I presume that a LOAD DATA INFILE would have the best performances, but you cannot use it with an excel file because it requires a text file. So if you would first convert your Excel file into a CSV format in C# with something like this .NET component for fast excel processing then you could use it.