So I have a really really really big pre-compiled MySQL Query Set. This query executes perfectly fine outside of my C# Application, but when I try to execute it in my C# application I run into a problem. Please note I can NOT modify the query itself nor can I recompile it in code, I need it to execute as is.
The query itself is comprised of a multitude of different queries that follow the following pattern:
DELETE FROM stores WHERE region_id = 1;
INSERT INTO stores (region_id, name, score, type) VALUES (17, '1', 0, 'Profit'),(17, '2', 0, 'Profit'),(17, '3', 0, 'Profit'),(17, '4', 0, 'Profit'),(17, '5', 0, 'Profit'),(17, '6', 0, 'NonProfit'),(17, '7', 0, 'NonProfit'),(17, '8', 0, 'NonProfit'),(17, '9', 0, 'NonProfit'),(17, '10', 0, 'NonProfit');
SELECT id INTO @store_id0 FROM stores WHERE region_id=17 AND name = '1' AND type = 'Profit';
INSERT INTO store_merch(store_id, item_id, stock) VALUES (@store_id0, 1360, 0),(@store_id0, 440, 5);
This works as expected when I execute it on something like navicat (database management tool), but with my C# program it generates the following exception:
Parameter '@store_id0' must be defined.
Here's my Query Execute function...
public bool ExecuteQuery(
string raw_query)
{
if (this.Open() == true)
{
//Create Command
MySqlCommand cmd = new MySqlCommand(raw_query, connection);
try
{
int changed_rows = cmd.ExecuteNonQuery();
if (changed_rows > 0)
{
this.Close();
return true;
}
else
{
Logger.GetInstance().Error("MySQLConnection::ExecuteQuery", "Zero records changed for in raw query.");
}
}
catch (MySqlException e)
{
Logger.GetInstance().Error("MySQLConnection::ExecuteQuery", e.Message);
}
this.Close();
}
return false;
}
Anyone know what the problem is?