Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1447

Problems with Source command (no replies)

$
0
0
Hi all,

I'm getting an exception:

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: 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 'source 4SightANPR_database.sql' at line 1

when attempting to use the source command via the c# implementation of the .net connector. The code is really simple:

MySqlConnection connection;
MySqlCommand command = new MySqlCommand();
connection = new MySqlConnection(connectionString);
command.Connection = connection;
connection.Open();

command.CommandText = "source 4SightANPR_database.sql";
command.ExecuteNonQuery();

It goes without saying that this runs fine from the mysql command line client. I don't think it's an issue with the file not being found, because when i type the wrong file name in the client, i get a specific error relating to an unknown file.

I've managed to find just one forum post relating to issues with the usage of the source command with the .net connector, but sadly that guy managed to find an answer in the archives, replied to his own post, but didn't link to the resolution he'd found - very frustrating! As I'm sure you can imagine, searching for anything with "source" in on the internet leads to kazillions of hits, so i've resorted to posting a direct question here about it. I've tried looking through the connector documentation on here, but can't find anything about a specific procedure to follow when attempting to use the source command. Most of the stuff i'm doing in this app is via stored procedures, but this is a create script run as part of the installation process for the whole system, so must be run from a file.

Obviously i can read the contents of the file in and execute it line by line if all else fails, but i'd rather do it this way if possible.

Many thanks for your time!

Simon

Viewing all articles
Browse latest Browse all 1447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>