Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: OutOfRangeException when opening connection to SQL


Message #1 by "Rob Taylor - tconsult.com" <rob@t...> on Thu, 6 Mar 2003 16:36:06 -0500
Hello all

I have been trying to tackle this problem for the last couple days and it is driving me nuts.  

"System.ArgumentOutOfRangeException: Index was out of range.  Must be non-negative and less 
than the size of the collection." 

The stack trace shows me that this happens where I open the connection (DataConn.open).  An example 
is below from the site but this is not the only place it happens.  It randomly happens on my database calls. 
It happens then if I refresh the screen it disappears.

    SQL = "execute SP_MakeInactive" 
    DataConn = new SQLConnection(SQLServer) 
    dbCommand = New SQLCommand(SQL,DataConn) 
     Try 
          DataConn.open 
          dbCommand.ExecuteNonQuery 
          Catch exp as exception 
          response.write(exp.ToString()) 
     Finally 
          DataConn.close 
     End Try 

The SQLServer string is in a codebehind file and the contents are below with all the parameters I am using in the string. 

Protected SQLServer as string = "Server=my.sql.server; 
                                 uid=foo; 
                                 pwd=fooman; 
                                 database=mydb; 
                                 connection lifetime=5; 
                                 connection reset=false; 
                                 Min Pool Size=1; 
                                 Max Pool Size=50;" 


I know this is long but I tried to give as much info as possible.  I am completely baffled so please enlighten 
me if you have any isights.  Thanks....Rob 


Message #2 by "Brian Smith" <bsmith@l...> on Sat, 8 Mar 2003 11:09:33 -0000
Never seen that error, but 2 suggestions:
1. remove the 'execute' from the command SQL
2. set the Command type to StoredProcedure

The error sounds more like the sort of thing you get when addressing a
DataGrid. Are you sure it's at the SQL execution stage?

brian

-----Original Message-----
From: Rob Taylor - tconsult.com [mailto:rob@t...] 
Sent: Thu, 06 Mar 2003 21:36
To: ADO.NET
Subject: [ado_dotnet] OutOfRangeException when opening connection to SQL


Hello all

I have been trying to tackle this problem for the last couple days and
it is driving me nuts.  

"System.ArgumentOutOfRangeException: Index was out of range.  Must be
non-negative and less 
than the size of the collection." 

The stack trace shows me that this happens where I open the connection
(DataConn.open).  An example 
is below from the site but this is not the only place it happens.  It
randomly happens on my database calls. 
It happens then if I refresh the screen it disappears.

    SQL = "execute SP_MakeInactive" 
    DataConn = new SQLConnection(SQLServer) 
    dbCommand = New SQLCommand(SQL,DataConn) 
     Try 
          DataConn.open 
          dbCommand.ExecuteNonQuery 
          Catch exp as exception 
          response.write(exp.ToString()) 
     Finally 
          DataConn.close 
     End Try 

The SQLServer string is in a codebehind file and the contents are below
with all the parameters I am using in the string. 

Protected SQLServer as string = "Server=my.sql.server; 
                                 uid=foo; 
                                 pwd=fooman; 
                                 database=mydb; 
                                 connection lifetime=5; 
                                 connection reset=false; 
                                 Min Pool Size=1; 
                                 Max Pool Size=50;" 


I know this is long but I tried to give as much info as possible.  I am
completely baffled so please enlighten 
me if you have any isights.  Thanks....Rob 



===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 27/01/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.449 / Virus Database: 251 - Release Date: 27/01/2003
 


  Return to Index