MySQL Connector: parameters not being added
- by LookitsPuck
Hey all!
Looking at my query log for MySQL, I see my parameters aren't being added. Here's my code:
MySqlConnection conn = new MySqlConnection(ApplicationVariables.ConnectionString());
MySqlCommand com = new MySqlCommand();
try
{
conn.Open();
com.Connection = conn;
com.CommandText = String.Format(@"SELECT COUNT(*) AS totalViews
FROM pr_postreleaseviewslog AS prvl
WHERE prvl.dateCreated BETWEEN (@startDate) AND (@endDate) AND prvl.postreleaseID IN ({0})"
, ids);
com.CommandType = CommandType.Text;
com.Parameters.Add(new MySqlParameter("@startDate", thisCampaign.Startdate));
com.Parameters.Add(new MySqlParameter("@endDate", endDate));
numViews = Convert.ToInt32(com.ExecuteScalar());
}
catch (Exception ex)
{
}
finally
{
conn.Dispose();
com.Dispose();
}
Looking at the query log, I see this:
SELECT COUNT(*) AS totalViews
FROM pr_postreleaseviewslog AS prvl
WHERE prvl.dateCreated BETWEEN (@startDate) AND (@endDate) AND prvl.postreleaseID IN (1,2)
I've used the MySQL .NET connector on countless projects (I actually have a base class that takes care of opening these connections, and closing them with transactions, etc.). However, I took over this application, and here I am now.
Thanks for the help!