Bug #26211 | Cannot create a new instance of MySqlParameterCollection | ||
---|---|---|---|
Submitted: | 9 Feb 2007 7:13 | Modified: | 27 Feb 2007 3:22 |
Reporter: | Matt | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / NET | Severity: | S5 (Performance) |
Version: | 5 | OS: | Windows (Windows) |
Assigned to: | CPU Architecture: | Any |
[9 Feb 2007 7:13]
Matt
[9 Feb 2007 8:02]
Paolo Niccolò Giubelli
I don't think this is a bug. Also in the .net framework the "SqlParameterCollection" is marked as internal, and this is consistent with the .NET architecture. You have to call the Add() method of the MySqlCommand.Parameters property if you want to add parameters to the collection.
[9 Feb 2007 13:46]
Reggie Burnett
This is not a bug. There is no need to create instances of MySqlParameterCollection. It should be accessed through the command object such as MySqlCommand cmd = new MySqlCommand(); cmd.Parameters.Add(...)
[27 Feb 2007 3:22]
Matt
You're right. Then the previous version of the driver which allows you to instantiate a new mysqlparametercollection object would be the bugged version. I apologize for the false alarm.
[8 Apr 2008 22:13]
Andrew Laughlin
I don't know that I would call this a bug so much as a design restriction. The code below abstracts away specific database architectures. This allows databases to be used in a polymorphic sense. However the code won't compile as MySqlParameterCollection doesn't define any constructors. I would like to see this ability added in future releases. public static class DbParameterCollectionFactory { public static DbParameterCollection GetDbParameterCollection() { return new MySql.Data.MySqlClient.MySqlParameterCollection(); } } Best Regards, Andrew
[8 Apr 2008 22:30]
Reggie Burnett
It's not a restriction because there's no need to create a parameter collection. DbCommand provides access to the parameter collection in a generic way. If you need to store the parameters in an array for later use then you can do that in a generic array.