Click here to Skip to main content
15,920,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am importing .csv file into mysql database throgh programmatically like blow.
can u help me...

string cs = "data source=localhost;database=databasename;uid=root;password=pwd;";

con = new MySqlConnection(cs);
cmd = new MySqlCommand("load data local infile 'D:\\Murali P\\MMM.csv' into table Excel fields terminated by ',' lines terminated by '\n' ignore 1 lines;", con);            
cmd.CommandTimeout = 2000;

In this case am getting blow error like...
"Fatal error encountered during command execution."
Updated 23-Apr-13 2:29am

Without seeing your system it is difficult to tell, but...where is drive "D"? is it on the same PC holding the MySQl Server instance? If so, does the user that MySql is running under have permissions to access the folder "Murali P" and the file "MMM.csv"?

If it isn't, you will get the problem. You might also want to have a look here:[^]
Share this answer
[no name] 23-Apr-13 3:38am    
drive "D" in same system only and permissions also given to file access from that path.
but i cannot understand the problem?
Your csv file contains (at least) one line which cannot be transformed into a row of the target table.
Try to find the defective lines. You can look thru them manually, or remove some lines from the file and try again.
Share this answer
your file specifications for LOAD DATA LOCAL INFILE should use forward slash (/) instead of backslash (\)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900