473,473 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GetOrdinal system.IndexOutOfRangeException

Using the following against a sql database, I get a
system.IndexOutOfRangeException for the column name Add_Date which is valid
field name and is a datetime field. All the other columns work ok. Does
anybody have any ideas. I'm new with .Net and this is driving me crazy.
Dim intTblAddDate As Integer = myReader.GetOrdinal("Add_Date")

Thanks in advance... Dick Bellnier

Nov 20 '05 #1
2 8003
Hello Dick,

I bet you $50 dollars or £ that the problem is that the select query does
not return this field. This is exactly what happens when you try and find an
ordinal which does not exist. I have replicated this problem.

Regards - OHM
be******@bellsouth.net wrote:
Using the following against a sql database, I get a
system.IndexOutOfRangeException for the column name Add_Date which is
valid field name and is a datetime field. All the other columns work
ok. Does anybody have any ideas. I'm new with .Net and this is
driving me crazy. Dim intTblAddDate As Integer =
myReader.GetOrdinal("Add_Date")

Thanks in advance... Dick Bellnier

Nov 20 '05 #2
You are correct. I've obmitted column names before in select statements
with VB6, but I thing this IndexOutOfRangeException message thru me a curve.
Thanks for the help...

"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@titan.btinternet.com...
Hello Dick,

I bet you $50 dollars or £ that the problem is that the select query does
not return this field. This is exactly what happens when you try and find an ordinal which does not exist. I have replicated this problem.

Regards - OHM
be******@bellsouth.net wrote:
Using the following against a sql database, I get a
system.IndexOutOfRangeException for the column name Add_Date which is
valid field name and is a datetime field. All the other columns work
ok. Does anybody have any ideas. I'm new with .Net and this is
driving me crazy. Dim intTblAddDate As Integer =
myReader.GetOrdinal("Add_Date")

Thanks in advance... Dick Bellnier


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kristian | last post by:
GetOrdinal can throw an IndexOutOfRangeException if the named item is not contained in the datareader. If i know that occsionally the column wont be in the datareader is there anyway i can test...
0
by: Juan Galdeano | last post by:
Hi, I'm working on an ONIX project and when I try to validate or read XML files C# gives me this exception: System.IndexOutOfRangeException at System.Xml.XmlScanner.ScanDtdContent() at...
1
by: Jay Allard | last post by:
Greetings When looping through a SQL Data Reader, it seems that it would be inefficient to call GetOrdinal(fieldname) multiple times. So, I thought I'd assign them to some variables before...
9
by: Tylius | last post by:
This one line is causing the issue, I've searched all over the net, but I can't seem to figure out why public static void Main(string args) { Console.WriteLine("Dice Roller"); try { int...
1
by: Robert Batt | last post by:
Hello, I have a problem deleting from a datagrid bound to a dataset. then datagrid is bound as follows MyDatagrid.DataSource = Mydataset.Tables(strtable this works fine for adding and...
5
by: c676228 | last post by:
Hi all, I am stuck with this problem. the code is like this: Dim sqlreader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection) ...
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
0
by: Susan | last post by:
I have an issue with the System.Collections.Generic.List that I can't find anywhere else... My website suddenly starts giving off System.IndexOutOfRangeException: Index was outside the bounds of...
0
by: =?Utf-8?B?aW1yYW4uYQ==?= | last post by:
Hi all, I am having a problem with inserting rows in to my datagridview control. The datagridview is bound to a bindingsource with a filter set. If i try and add a row to the datagridview while...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.