|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
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. |
#2
| |||
| |||
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?) |
#3
| |||
| |||
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. |
#4
| |||
| |||
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. |
![]() |
|
Tags: datareader, myodbc driver, mysql, parameterized queries |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to manage databases and tables in MySQL? | Aahlaadith | Software Development | 5 | 17-12-2010 07:18 AM |
Optimizing queries in MySQL | Caden Fernandes | Software Development | 4 | 05-03-2010 07:14 PM |
How to Run MySQL Queries with PHP? | Rob Dizzle | Software Development | 4 | 05-02-2010 05:40 AM |
Show Number of MySQL Queries | Jagriti | Software Development | 3 | 28-07-2009 03:17 PM |
Need to have multiple where queries in MySQL query | Anti_Trend | Software Development | 1 | 03-07-2009 10:17 PM |