当我试图执行折叠代码时,会在NullReferenceException上引发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
}
}以下是消息异常:
System.NullReferenceException: La référence d'objet n‘’est définieàune实例d‘’un objet。在Microsoft.Win32.Win32Native.CopyMemoryUni(StringBuilder pdst,IntPtr psrc,IntPtr sizetcb),在System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr),在IBM.Data.DB2.iSeries.MPHostCol.setHostColInfo(MpDcHostColumnInfo dcHostColInfo( blahblahblah ),直到上线。
每个参数都被填充,查询使用SQL-view正确执行,连接字符串正确,数据库类型正常.作为每一种静态方法,无需设置任何其他方法.我肯定这是件蠢事,但我想不出是什么。
发布于 2011-08-09 06:56:00
该死,从V5R3到V5R4的更新解决了这个问题。一个简单的15分钟更新解决了3天的头部撞击。很高兴作出以下贡献:)
https://stackoverflow.com/questions/6982785
复制相似问题