title: MySQL Load Data Infile
body: <p>I want to import CSV file into MySQL database but I am getting an error.</p>
  
  <p>This is my method for <code>LOAD DATA INFILE</code>:</p>
  
  <pre><code>public int Import(string path)
  {
     try
     {
        string cmd = "LOAD DATA INFILE " + path + " INTO TABLE zen_hardware.products FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'";
  
        int a = MySqlHelper.ExecuteNonQuery(conn.Connect(),cmd);
  
        return a;
     }
     catch
     {
        return -1;
     }
  }
  </code></pre>
  
  <p>When I run the code my string cmd gets this:</p>
  
  <pre><code>"LOAD DATA INFILE c:\\users\\trabajo\\documents\\visual studio 2013\\Projects\\Zen Hardware\\Presentation\\Tarjetas de Video.csv INTO TABLE zen_hardware.products FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'"
  </code></pre>
  
  <p>And the error I get is this:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to use
    near 'c:\users\trabajo\documents\visual studio 2013\Projects\Zen
    Hardware\Presentation'</p>
  </blockquote>
  
  <p>I don't know what part of my cmd syntax is wrong.</p>