首页 新闻 会员 周边 捐助

oracle 查询报错

0
[已关闭问题] 关闭于 2018-01-12 15:24

  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报错,求大神

独孤正龙的主页 独孤正龙 | 菜鸟二级 | 园豆:202
提问于:2017-11-27 19:12
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册