1


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...

1
  • Try /export/person.csv? Since this question has nothing to do with C# (or your application), you might want to ask on a MySql forum, specifically the provider of the Windows port. Commented Feb 19, 2011 at 17:40

2 Answers 2

1

I solved this problem..

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

after this my program works correctly...

Sign up to request clarification or add additional context in comments.

Comments

0

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.