Bug #24728 Connector/NET 1.0.8 is not backwards compatible with Connector/NET 1.0.7

Submitted: 30 Nov 2006 17:05 Modified: 1 Dec 2006 13:50
Reporter: Paul Bonfanti Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.8 OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[30 Nov 2006 17:05] Paul Bonfanti
Description:
Connector/NET 1.0.8 is not backwards compatible with Connector/NET 1.0.7 when it comes to prepared statements.  With 1.0.7 you could add a parameter for a prepared statement just using the number of the parameter.  With 1.0.8 you need to add it using a question mark before the number of the parameter.  For example, the following works in 1.0.7:

MySqlParameter parm = command.get_Parameters().Add("1", MySqlDbType.VarString);

but must be changed to the following in 1.0.8:

MySqlParameter parm = command.get_Parameters().Add("?1", MySqlDbType.VarString);

How to repeat:
Here's an example that works with 1.0.7 but fails with 1.0.8:

package MySQLPreparedStatement;

import MySql.Data.MySqlClient.*;

/**
 * Summary description for Program
 */
public class Program
{
	public static void main(String[] args)
	{
		String connectString = "server=tennis;database=test;user id=root;password=root";
		MySqlConnection connection = new MySqlConnection(connectString);
		connection.Open();

		MySqlCommand command = new MySqlCommand();
		command.set_Connection(connection);
		command.set_CommandType(System.Data.CommandType.Text);
		command.set_CommandText("select * from bdnetdata where app = ?1");

		MySqlParameter parm = command.get_Parameters().Add("1", MySqlDbType.VarString);
		parm.set_Direction(System.Data.ParameterDirection.Input);
		parm.set_Value("BD_Unnamed_App");
		parm.set_Size("BD_Unnamed_App".length());

		command.Prepare();
		MySqlDataReader reader = command.ExecuteReader();
		while (reader.Read())
		{
			int num = reader.get_FieldCount();
			for (int i = 0; i < num; i++)
				System.out.println(reader.get_Item(i));
		}
	}
}

Suggested fix:
With prepared statements, allow just the number of the parameter to be used as the parameter name.
[1 Dec 2006 13:50] Tonci Grgin
Hi Paul and thanks for your problem report. This is a documented change,
    Increased speed of MySqlParameterCollection.IndexOf(string) orders of magnitude (parameter name lookups are now strict on use of parameter marker)

due to completely new parameter lookup code.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.