System.Data.ProviderBase.FieldNameLookup.GetOrdinal中的SQL DataReader IndexOutOfRangeException [英] SQL DataReader IndexOutOfRangeException at System.Data.ProviderBase.FieldNameLookup.GetOrdinal

查看:495
本文介绍了System.Data.ProviderBase.FieldNameLookup.GetOrdinal中的SQL DataReader IndexOutOfRangeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到 < g class =" gr_ gr_71 gr-alert gr_gramm gr_hide gr_inline_cards gr_run_anim Style multiReplace replaceWithoutSep"数据-GR-ID =" 71" ID = QUOT; 71"> IndexOutOfRangeException&NBSP;同时抑制; / g取代;使用SQL数据读取器检索
数据。

I am experiencing the <g class="gr_ gr_71 gr-alert gr_gramm gr_hide gr_inline_cards gr_run_anim Style multiReplace replaceWithoutSep" data-gr-id="71" id="71">IndexOutOfRangeException  while</g> retrieving data with SQL Data Reader.

存储过程返回正确的数字列,并且在ADO.NET代码中访问相同的数据。

The stored procedure is returning the correct number columns and same is accessed in ADO.NET code.

相同的代码和存储过程在一个环境中工作,在另一个环境中失败。

Same code and the stored procedure is working in one environment and failing in another environment.

两个环境都有相同的代码。

Both environments have identical code.

是否有人< ; g class =" gr_ gr_160 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace"数据-GR-ID =" 160" ID = QUOT; 160">面及LT; / g取代;这类问题?

Did anybody <g class="gr_ gr_160 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="160" id="160">faced</g> this kind of issue?

问候,Nakul

推荐答案

请发布您正在使用的代码以及您获得的数据示例返回。

Please post the code you're using and an example of the data you are getting back.

错误显然是尝试获取结果集中不存在的列,因此您只需要弄清楚它失败的原因。幸运的是,你可能会做这样的事情。

The error is clearly an attempt to get a column that doesn't exist in the resultset so you just need to figure out why it is failing. Fortunately you're probably doing something like this.

myData["SomeColumn"]




因此异常将在导致问题的行上。该异常将包含行信息,并告诉您确切的行。然后,您可以查看调试器中的数据并确认该列实际存在。我怀疑它没有。


So the exception will be on the line causing the issue. The exception will contain the line information and that tells you exactly which line. You can then look at the data in the debugger and confirm the column actually exists. I suspect it doesn't.


这篇关于System.Data.ProviderBase.FieldNameLookup.GetOrdinal中的SQL DataReader IndexOutOfRangeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆