when I try to execute the folowing code, a NullReferenceException is raised on the ExecuteReader:
static public IDataReader executeReader(string query, string connectionString, string databaseType)
{
switch(databaseType)
{
case "SqlServer":
//stuff for Sql Server
case "DB2":
iDB2Connection myConnectionDB2 = new iDB2Connection(connectionString);
iDB2Command sqlCommandDB2 = new iDB2Command(query, myConnectionDB2);
sqlCommandDB2.CommandTimeout=0;
try
{
sqlCommandDB2.Connection.Open();
***The exception is raised here...***
return sqlCommandDB2.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception e)
{
sqlCommandDB2.Dispose();
myConnectionDB2.Close();
throw new Exception("Error in DBHelper:ExeSQL()-> " + e.ToString());
}
default:
//stuff for Oracle
}
}
Here is the message exception:
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet. at Microsoft.Win32.Win3开发者_如何转开发2Native.CopyMemoryUni(StringBuilder pdst, IntPtr psrc, IntPtr sizetcb) at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr) at IBM.Data.DB2.iSeries.MPHostCol.setHostColInfo(MpDcHostColumnInfo dcHostColInfo) blahblahblah until the line above.
Every parameter is filled, the query execute correctly with SQL-view, the connection string is correct and the database type is ok... As every static method, nothing else have to be set... i'm sure it's somethin' stupid, but can't figure what.
Damn, the update from V5R3 to V5R4 has solved the bug. A simple 15 minutes update solved 3 days of head banging. Glad to have contributed :)
精彩评论