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.
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:
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 :
Dim parameters() As SqlParameter = New SqlParameter(6 + 1)
not
Dim parameters() As SqlParameter = New SqlParameter(6 - 1)
Can you tell me is this a bug and how to fix it?
Thanks
Derek