0

当我启动页面进行调试时,我收到以下异常。objectDataSource 是为查询 oracle 数据库的 ADO TableAdapter 配置的。然后将 ods 绑定到 ASP.NET Gridview。我正在针对 .NET 4.0 进行编码。

如果我不绑定gridview,启动时没有问题。我可以完全配置 ods,为 gridview 定义列和行行为等,没有任何问题。我正在使用(据我所知)我过去成功使用过多次的相同方法来访问和显示数据。我已经尽可能地仔细阅读了代码,但无法找出问题所在。

异常信息:

Capabilities:Type=IE7,Name=IE,Version=7.0,MajorVersion=7,MinorVersion=0,Platform=WinNT,IsBeta=False,IsCrawler=False,IsAOL=False,IsWin16=False,IsWin32=True,SupportsFrames=True,SupportsTables=True,SupportsCookies=True,Ecmascriptversion=3.0,SupportsVBScript=True,SupportsJavaApplets=True,SupportsActiveXControls=True,CDF= False 

Inner Exception Type: System.Reflection.TargetInvocationException Inner Exception: Exception has been thrown by the target of an invocation. 
Inner Source: mscorlib 
Inner Stack Trace: at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) 
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) 
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) 
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) 
at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) 
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) 
at System.Web.UI.WebControls.DataBoundControl.PerformSelect() 
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() 
at System.Web.UI.WebControls.GridView.DataBind() 
at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() 
at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() 

标记:

<asp:GridView ID="gvGradename" runat="server" AutoGenerateColumns="False" 
                    DataKeyNames="GRADENAME_ID" DataSourceID="odsGradename">
                    <Columns>

                        //Which columns are displayed are irrelevant. The error occurs with any columns, including none.

                    </Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsGradename" runat="server" 
                    OldValuesParameterFormatString="original_{0}" 
                    SelectMethod="GetDataByActiveName" 
                    TypeName="pts.PTSTableAdapters.PTS_GRADENAMETableAdapter">
</asp:ObjectDataSource>

查询:

select gn.gradename_id 
      , gn.mill_id
      , case when gn.gradename_id = 0 then upper(gn.name) else initcap(gn.name) end name
      , m.name millname
      , gn.audit_id
      , gn.audit_dtm
      , gn.audit_insert_dtm
      , gn.audit_process_code
      , gn.description
      , gn.roll_width_threshold
from pts_gradename gn
  , pts_mill m
where gn.is_generic = 1 
  and gn.is_active = 1
  and gn.mill_id = m.mill_id
order by case when gn.gradename_id = 0 then null else initcap(gn.name) end nulls first 

目前,我没有在代码隐藏中对它做任何事情。

编辑:在查询中包含表名,它们以前被编辑过。

此外,我可以预览表适配器中的数据,并接收预期的信息,因此查询本身似乎没有问题。

4

1 回答 1

0

问题出在与数据表关联的自动生成的 Fill 方法上。我无法确定究竟是什么问题,但删除它并重新开始解决了问题。

不是一个很好的答案,但它是这个特定问题的解决方案。

于 2013-04-01T17:53:52.293 回答