How to manage Parameterized Queries in MySQL
I'm using MySQL with the MyODBC driver. But MySQL is tricky, it doesn't support named parameters, so you have to use a question mark and add parameters in the right order. To connect to MySQL database you can use the System.Data.Odbc namespace in .net. If I remove them and just explicitly put in the data I'm looking for the datareader works, however doing as I have below returns no results in the datareader.
Re: How to manage Parameterized Queries in MySQL
If your database is so poor that it doesn't support parameterized queries, You should look into using the ByteFX MySQL library. It's a native MySQL interface for .NET, so you don't have to use ODBC or ODBC drivers. you might want to build your own format() style function that replaces $values in your query.That seems to be working earlier in your code. Are you sure there is a value to read there (i.e. is your query returning 0 rows or null or something else that can't be converted to a string?)
Re: How to manage Parameterized Queries in MySQL
Looks like that procedure works fine on the line account1Name = r.GetValue(0).ToString();. Maybe you want to check the return value of r.Read() to see if there are any rows first. You should look into using the ByteFX MySQL library. It's a native MySQL interface for .NET, so you don't have to use ODBC or ODBC drivers.
Re: How to manage Parameterized Queries in MySQL
Coming from SQL Server and Oracle, It looks like you're trying to get a single value out of a query. You might want to look into the ExecuteScalar() method instead of ExecuteReader(). I was so used to using named parameters that I totally forgot the questionmark approach. This being my first MySQL project, I was about to knock my head through the wall wondering why that database wasn't accepting my update statements.