try
{
sql = sql.Replace("P_start", (index * number+1).ToString()).Replace("Pend", ((index+1) * number).ToString());
OpenConn();
LogHelper.Write(string.Format("ExcuteSelectSql== {0} ", sql));
System.Data.DataSet ds = new DataSet();
OracleDataAdapter Ada = new OracleDataAdapter(sql, conn);
Ada.AcceptChangesDuringFill = true;
Ada.AcceptChangesDuringUpdate = true;
if (tableName == "") tableName = "oracle_data";
Ada.Fill(ds, tableName);
LogHelper.Write(string.Format("ExcuteSelectSql==table Name :{0},rows: {1} ", tableName, ds.Tables[0].Rows.Count));
CloseConn(conn);
return ds.Tables[0];
}
catch (Exception ex)
{
LogHelper.Write("ExcuteSelectSql:" + ex.ToString());
CloseConn(conn);
return null;
}
异常信息:
System.InvalidCastException: Specified cast is not valid.
at Oracle.ManagedDataAccess.Client.OracleDataReader.GetDecimal(Int32 i)
at Oracle.ManagedDataAccess.Client.OracleDataReader.GetValue(Int32 i)
at Oracle.ManagedDataAccess.Client.OracleDataReader.GetValues(Object[] values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at Oracle.ManagedDataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at Oracle.ManagedDataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
所有sql 在plsql中正常执行,但是.net 有的sql 正常,有的sql报错,求大神