Bug #5509 Parameter.DbDType = DbType.X Null Reference Exception

Submitted: 10 Sep 2004 3:16 Modified: 16 Sep 2004 14:11
Reporter: Lon Palmer Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:1.0.0.22722 OS:Windows (Windows XP)
Assigned to: Assigned Account CPU Architecture:Any

[10 Sep 2004 3:16] Lon Palmer
Description:
The following Code produces a Null Reference Exception at the DbType line in the newest version of the software.  This code ran witout error using ByteFx .76:

cmd.CommandText = sqlGetById;
IDbDataParameter idp = cmd.CreateParameter();
idp.ParameterName = "@Id";
idp.DbType = DbType.Int32;  // NULL REFERENCE HERE!!!!
cmd.Parameters.Add( idp );
idp.Value = id;
cmd.Prepare();

cmd is of type IDbCommand and was instanciated like:

public UserIMailGetCmd( IDbConnection con )
		{
			this.con = con;
			cmd = con.CreateCommand();
			cmd.CommandType = CommandType.Text;
		}

The Exception thrown is:

System.NullReferenceException: Object reference not set to an instance of an object. at MySql.Data.MySqlClient.MySqlParameter.set_DbType(DbType value) at BHMailAgent.Data.UserIMailGetCmd.GetUser(Int32 id) in c:\inetpub\wwwroot\bhmailagent\data\userimailgetcmd.cs:line 27 at BHMailAgent.index.PopUserParams(Int32 userId) in c:\inetpub\wwwroot\bhmailagent\index.aspx.cs:line 137
at MySql.Data.MySqlClient.MySqlParameter.set_DbType(DbType value) at BHMailAgent.Data.UserIMailGetCmd.GetUser(Int32 id) in c:\inetpub\wwwroot\bhmailagent\data\userimailgetcmd.cs:line 27 at BHMailAgent.index.PopUserParams(Int32 userId) in c:\inetpub\wwwroot\bhmailagent\index.aspx.cs:line 137

How to repeat:
My guess is that any code setting a DbType on an IDbParameter object will throw this err.r

Suggested fix:
Unknown.  I tried to import your code to walk through it but I could not.  I could not user your references.  Also, the test suite will not run because I don't have NUnit????? Where is that?
[16 Sep 2004 13:06] Reggie Burnett
I know this bug has been fixed but I also believe it was reported earlier.  In any case, it is fixed in beta 2
[16 Sep 2004 13:59] Lon Palmer
Reggie,

Is this fix available in a nightly build form?  If so where would that be located?

Thanks,

Lon Palmer
[16 Sep 2004 14:11] Reggie Burnett
Not in a nightly build but it can be pulled from our public source repository by using bitkeeper.

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

Page generated in 0.051 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.