Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Designer> RetrievalProcedures Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
 

Pages: 1
Designer
RetrievalProcedures Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Page:1/1 

  Print all messages in this thread  
Poster Message
DerekLi
User



Location:

Joined on:
08-Aug-2007 20:27:45
Posted:
8 posts
# Posted on: 28-Aug-2007 21:04:03.  
owing VB.NET Code is generated from LLBLGen 2.0 which is for the data retrieval i HAVE
I have a data retrieval stored procedure [dbo].[spJackpot_All] shown below.

Code:
PROCEDURE [dbo].[spJackpot_All]
@minDate as datetime,
@maxDate as datetime,
@callin as char(1),
@both as char(1),
@region_id as char(3),
@all as char(1)
AS
BEGIN
SELECT * FROM MYTABLE
END



The VB.NET code generated from LLBLGen 2.0 is as follows:

Code:
Public Shared Function SpJackpotAll(minDate As System.DateTime, maxDate As System.DateTime, callin As System.String, both As System.String, regionId As System.String, all As System.String, ByRef returnValue As System.Int32, adapter As DataAccessAdapter) As DataSet
    ' create parameters. Add 1 to make room for the Return value parameter.
    Dim parameters() As SqlParameter = New SqlParameter(6 - 1) {}
    parameters(0) = new SqlParameter("@minDate", SqlDbType.DateTime, 0, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Current, minDate)
    parameters(1) = new SqlParameter("@maxDate", SqlDbType.DateTime, 0, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Current, maxDate)
    parameters(2) = new SqlParameter("@callin", SqlDbType.Char, 1, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Current, callin)
    parameters(3) = new SqlParameter("@both", SqlDbType.Char, 1, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Current, both)
    parameters(4) = new SqlParameter("@region_id", SqlDbType.Char, 3, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Current, regionId)
    parameters(5) = new SqlParameter("@all", SqlDbType.Char, 1, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Current, all)

    parameters(6) = New SqlParameter("RETURNVALUE", SqlDbType.Int, 0, ParameterDirection.ReturnValue, True, 10, 0, "", DataRowVersion.Current, returnValue)
    Dim toReturn As DataSet = New DataSet("SpJackpotAll")
    Dim hasSucceeded As Boolean = adapter.CallRetrievalStoredProcedure("[SHSDev].[dbo].[spJackpot_All]", parameters, toReturn)


    returnValue = CType(parameters(6).Value, Integer)
    Return toReturn
End Function


When running the code above, following exception is thrown:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Agco.Shs.DataAccess.Server.DatabaseSpecific.RetrievalProcedures.SpJackpotAll(DateTime minDate, DateTime maxDate, String callin, String both, String regionId, String all, Int32& returnValue, DataAccessAdapter adapter) in C:\Projects\EG\Agco.Shs\Agco.Shs.DataAccess\Agco.Shs.DataAccess.Server\ DatabaseSpecific\RetrievalProcedures.vb:line 230 ......


Apparently, the code generated is wrong when defining the dimension for the parameter array.

Code generated should be :

Code:
Dim parameters() As SqlParameter = New SqlParameter(6 + 1)

not
Code:
Dim parameters() As SqlParameter = New SqlParameter(6 - 1)


Can you tell me is this a bug and how to fix it?

Thanks

Derek
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14637 posts
# Posted on: 29-Aug-2007 09:41:02.  
Please provide more information as stated here:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7721
Which release date/build of the LLBLGen Pro are you using? (Designer->Help->About)
Adapter or SelfServicing templates?

Please make sure you use the latest available version of LLBLGen Pro, and then re-generate, the code and check whether the problem still exists or not.


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38081 posts
# Posted on: 29-Aug-2007 10:57:53.  
Template bug. Will fix it. The C# template has +1, the vb.net template has -1. This of course isn't correct.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
DerekLi
User



Location:

Joined on:
08-Aug-2007 20:27:45
Posted:
8 posts
# Posted on: 29-Aug-2007 13:28:20.  
The version is 2.0.0.0 Final Released on February 14th, 2007.

How do I fix the template?

Thanks

Derek


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38081 posts
# Posted on: 29-Aug-2007 13:41:31.  
DerekLi wrote:
The version is 2.0.0.0 Final Released on February 14th, 2007.

How do I fix the template?

Thanks

Derek

In:
Templates\SqlServerSpecific\Net2.x\VB.NET\retrievalProceduresAdapter.template, you'll find code like:
Dim parameters() As SqlParameter = New SqlParameter(<[AmountOfParameters]> - 1)

Change the second time you see that in
Dim parameters() As SqlParameter = New SqlParameter(<[AmountOfParameters]>)

You can also call the overload which doesn't have a return parameter. This one should work without altering the template. As your proc doesn't return a returnparameter, it's not necessary to call the one which returns a return parameter.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
DerekLi
User



Location:

Joined on:
08-Aug-2007 20:27:45
Posted:
8 posts
# Posted on: 29-Aug-2007 13:45:20.  
Thanks for the quick reply.

Will this change also be made in your future release or fix and when?

Is the Version I am using the latest one?

Thanks again.

Derek


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38081 posts
# Posted on: 29-Aug-2007 14:30:31.  
DerekLi wrote:
Thanks for the quick reply.

Will this change also be made in your future release or fix and when?

Is the Version I am using the latest one?

Thanks again.

Derek

We have v2.5 out since a couple of days, so you should check that one out Regular Smiley. The fix will be released soon, though you can work around it today (by calling the other overload) so you don't have to wait till we've released the fix.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.