Bug #30300 Array index out of range when use Parametric SQL + AddWithValue and ExecuteQuery
Submitted: 8 Aug 2007 10:29 Modified: 25 Sep 2007 16:34
Reporter: danilo priore Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.07 OS:Windows (XP SP2)
Assigned to: CPU Architecture:Any
Tags: AddWithValue, ExecuteQuery

[8 Aug 2007 10:29] danilo priore
Description:
When i execute a parametric query (SELECT * FROM myTable WHERE id=?) with ExecuteQuery, and before create the parameter with MySqlCommand.Parameters.AddWithValue, the execution method return an error "Array index out of range." (???)

Danilo

How to repeat:
Create a parametric query, create connection, create a parameter command, execute query.
[14 Aug 2007 0:05] MySQL Verification Team
Thank you for the bug report. Please provide a complete test case code.
Thanks in advance.
[14 Sep 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[19 Sep 2007 13:27] danilo priore
Public Function GetCustomer(ByVal ID AS Integer) AS DataSet
	Dim sqlConn As MySqlConnection = New MySqlConnection("Database=prioregroup;Data Source=localhost;User Id=root;Password=1234")
	Dim sqlCmd As MySqlCommand = New MySqlCommand("SELECT * FROM Customers WHERE ID=?", sqlConn)
	sqlCmd.Parameters.AddWithValue("@id", ID)
	Dim sqlDA As MySqlDataAdapter = New MySqlDataAdapter(sqlCmd)
	Dim sqlDS AS As DataSet = New DataSet
	sqlDA.Fill(sqlDS)
	Return sqlDS
End Function
[21 Sep 2007 21:33] Reggie Burnett
This is not a bug.  You need to use the ? syntax when adding your parameter.
[25 Sep 2007 16:34] danilo priore
i have tray with @param-name and with '?' char, but not work, please send to me a example work fine ?
[26 Sep 2007 16:29] Reggie Burnett
Please have a look at the test suite that is in our source distribution.  There are many examples there of using parameters.