dbTalk Databases Forums  

ColumnIndexOutOfRangeException

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss ColumnIndexOutOfRangeException in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Joe Cool
 
Posts: n/a

Default ColumnIndexOutOfRangeException - 07-23-2010 , 05:25 PM






I am trying to run a query from a C#.NET application using the
standard SqlClient connected to a SQL2005 database. Basically the
query is:

select count(*) from table1 where column1 is not null or column1 > 0

table1 exists and contains a column named column1. column1 is an int
datatype and allow nulls. If I run the query from a query window in
the SQL Server Management Studio, it runs just fine.

However if I run it from the C#.NET app, the
ColumnIndexOutOfRangeException is being thrown. The message text is
"index was outside the bounds of the array".

Any ideas?

Reply With Quote
  #2  
Old   
Joe Cool
 
Posts: n/a

Default Re: ColumnIndexOutOfRangeException - 07-23-2010 , 05:52 PM






On Jul 23, 6:25*pm, Joe Cool <joecool1... (AT) live (DOT) com> wrote:
Quote:
I am trying to run a query from a C#.NET application using the
standard SqlClient connected to a SQL2005 database. Basically the
query is:

select count(*) from table1 where column1 is not null or column1 > 0

table1 exists and contains a column named column1. column1 is an int
datatype and allow nulls. If I run the query from a query window in
the SQL Server Management Studio, it runs just fine.

However if I run it from the C#.NET app, the
ColumnIndexOutOfRangeException is being thrown. The message text is
"index was outside the bounds of the array".

Any ideas?
Well, now I am not sure if this a problem or not. Actually, I was
seeing this in a VB.NET program that I am converting to C#.NET. This
app produces a report based on the content of a database. I wanted to
generate the report with the VB version so I could make sure the
output of the C# version was identical. I now have the C# version in
testing mode and I am not getting this error with it.

Go figure.

Reply With Quote
  #3  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: ColumnIndexOutOfRangeException - 07-24-2010 , 05:42 AM



Joe Cool (joecool1969 (AT) live (DOT) com) writes:
Quote:
On Jul 23, 6:25*pm, Joe Cool <joecool1... (AT) live (DOT) com> wrote:
I am trying to run a query from a C#.NET application using the
standard SqlClient connected to a SQL2005 database. Basically the
query is:

select count(*) from table1 where column1 is not null or column1 > 0

table1 exists and contains a column named column1. column1 is an int
datatype and allow nulls. If I run the query from a query window in
the SQL Server Management Studio, it runs just fine.

However if I run it from the C#.NET app, the
ColumnIndexOutOfRangeException is being thrown. The message text is
"index was outside the bounds of the array".

Any ideas?

Well, now I am not sure if this a problem or not. Actually, I was
seeing this in a VB.NET program that I am converting to C#.NET. This
app produces a report based on the content of a database. I wanted to
generate the report with the VB version so I could make sure the
output of the C# version was identical. I now have the C# version in
testing mode and I am not getting this error with it.
Whatever, the error is a VB error, and I don't think you will get
much help with it in an SQL newsgroup. Particularly if you don't
include the VB code.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.