0

When I run the following MySQL query using the MySQL connector, in c#, using ExecuteNonQuery(), I get a fatal error:

LOAD DATA LOCAL INFILE '//Path hidden//' 
INTO TABLE unvisted_urls 
   FIELDS ENCLOSED BY '"' TERMINATED BY ',' 
   LINES TERMINATED BY '\r\n' 
(@url_hash, url,link_name)  
SET url_md5=UNHEX(@url_hash);

The error I get is:

{"Parameter '@url_hash' must be defined."}

If I run the same query in SQLWorkbench56, I don't get any errors and the data is imported correctly.

The problem was introduced after including @url_hash parameter. Have I got the syntax correct or am I missing something.

erik258
  • 14,701
  • 2
  • 25
  • 31

1 Answers1

1

Ok after some further research I found that the following question answered my problem:

Is it possible to use a MySql User Defined Variable in a .NET MySqlCommand?

The problem seems to be related to needing to set "Allow User Variables=True" as part of your connection string after setting the password, server database etc.

The original source for the solution can be found in this Blog.

I've answered my own question to try and help other users who come across this obscure issue.

Community
  • 1
  • 1