| Bug #7439 | Exception preparing a select statement with one parameter | ||
|---|---|---|---|
| Submitted: | 20 Dec 2004 18:57 | Modified: | 5 Jan 2005 18:21 |
| Reporter: | [ name withheld ] | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | Connector / NET | Severity: | S1 (Critical) |
| Version: | 1.0.3 | OS: | Windows (Windows XP) |
| Assigned to: | Reggie Burnett | CPU Architecture: | Any |
[5 Jan 2005 18:21]
Reggie Burnett
Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.mysql.com/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to 'Open'. Thank you for your interest in MySQL. Additional info: What version of MySQL are you using? I think I fixed this already. Please test your code with 1.0.4 that will be out soon and let me know if I can close this.

Description: The following exception happens preparing a simple select statement containing one parameter: MySql.Data.MySqlClient.MySqlException: Expected end of data packet at MySql.Data.MySqlClient.NativeDriver.ReadEOF(Boolean readPacket) at MySql.Data.MySqlClient.NativeDriver.Prepare(String sql, String[] parmNames) at MySql.Data.MySqlClient.MySqlCommand.Prepare() at Test.Class1.Main(String[] args) in d:\test\class1.cs:line 39 How to repeat: 1. Create the table and insert one record: create table twocolumns (one integer, two integer); insert into twocolumns values (1, 2); 2. Execute the following C# code: IDbConnection cnn = new MySqlConnection(); cnn.ConnectionString = "Database=test;Data Source=server;User Id=uid;Password=pwd"; cnn.Open(); // create the command and prepare the statement IDbCommand cmd = cnn.CreateCommand(); cmd.CommandText = "SELECT * FROM twocolumns where one = ?p1"; // create the parameter IDbDataParameter p1 = cmd.CreateParameter(); p1.ParameterName = "p1"; p1.DbType = DbType.Int32; p1.Precision = (byte)10; p1.Scale = (byte)0; p1.Size = 4; cmd.Parameters.Add(p1); // prepare the command cmd.Prepare(); // set the parameter value p1.Value = 1; // Execute the reader IDataReader reader = cmd.ExecuteReader(); // Fetch the first record reader.Read(); // Close the connection cnn.Close();