problem with mysql export to file in c#
FolderBrowserDialog fol=new FolderBrowserDialog();
if (fol.ShowDialog() == DialogResult.OK)
{
string path= fol.SelectedPath;
string sql = "SELECT * INTO OUTFILE '" + path+ "\person.csv' FIELDS TERMINATED BY',' OPTIONALLY ENCLOSED BY '\"' LINES开发者_开发百科 TERMINATED BY '\n' FROM tpers ";
MySqlCommand daa = new MySqlCommand(sql, conn);
conn.Open();
daa.ExecuteNonQuery();
conn.Close();
}
for example
path = "c:\export" but when i execute this code it doesnt export person.csv to intended path. it creates "c:export\person.csv" file and creates this file in mysql/data folder.. can u explain the problem, and how to fix it...I solved this problem..
string path = fol.SelectedPath;
path = path.Replace("\\","/");
...
after this my program works correctly...
Works for me!! In my case needed to do in c#. Used with the MySql.Data.dll v6.4.4
LOAD DATA LOCAL INFILE 'C:/Program Files/MySQL/MySQL Server 5.7/bin/test.csv' REPLACE INTO TABLE test_tmp CHARACTER SET UTF8 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES (field1,field2,field3,field4,field5);
精彩评论