I cannot figure out why this code will not work. I have verified the database is configured to accept load data infile and the connection opens ok, but the command string fails with a fatal error ...the syntax for the command string works with the admin tool and all i have changed is the filename to the variable named target. the file exists and imports manually fine. why not here? any ideas? Please!!!
//=====================
string myConnectionString =
"Data Source=" + mshost + ";" +
"Database=CA_DB;" +
"Port=" + msport + ";" +
"Persist Security Info=yes;" +
"allow user variables=true;" +
"UserId=" + msacct + ";" +
"PWD=" + mspass + ";";
MySqlConnection mycon = new MySqlConnection( myConnectionString );
string cmdstring = "LOAD DATA LOCAL INFILE '" + target + "' INTO TABLE CA_TABLE FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n'; ";
MySqlCommand mycommand = new MySqlCommand(cmdstring, mycon );
try
{
mycon.Open();
mycommand.ExecuteNonQuery();
mycon.Close();
return true;
}
catch (MySqlException ex)
{
MessageBox.Show( ex.Message + "\nError number: " + ex.Number, "Import Error" );
return false;
}
//=====================
string myConnectionString =
"Data Source=" + mshost + ";" +
"Database=CA_DB;" +
"Port=" + msport + ";" +
"Persist Security Info=yes;" +
"allow user variables=true;" +
"UserId=" + msacct + ";" +
"PWD=" + mspass + ";";
MySqlConnection mycon = new MySqlConnection( myConnectionString );
string cmdstring = "LOAD DATA LOCAL INFILE '" + target + "' INTO TABLE CA_TABLE FIELDS TERMINATED BY '|' LINES TERMINATED BY '\r\n'; ";
MySqlCommand mycommand = new MySqlCommand(cmdstring, mycon );
try
{
mycon.Open();
mycommand.ExecuteNonQuery();
mycon.Close();
return true;
}
catch (MySqlException ex)
{
MessageBox.Show( ex.Message + "\nError number: " + ex.Number, "Import Error" );
return false;
}