problem with mysql export to file in c#

Issue

i have a problem with mysql+c# in mysql export operation.

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…

Solution

I solved this problem..

string path = fol.SelectedPath;
path = path.Replace("\\","/");
...

after this my program works correctly…

Answered By – namco

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published