Specified Cast Is Not Valid Exception

Posts   
 
    
Posts: 8
Joined: 03-Sep-2009
# Posted on: 27-Jan-2010 15:36:23   

Hello,

We're using run-time version 2.0.50727. We recently updated our SQL Anywhere EDF to 11.0.1.2355. After doing this, one of our action stored procedures has been throwing a 'Specified Cast is not Valid' exception when it had been working fine before. Here is the header to the stored procedure:


create procedure DBA.GetEmployeeIdWithNextException( 
  in @employeeIds long varchar,
  in @exceptionIds long varchar,
  in @payPeriodId integer,
  in @companyId integer,
  inout @empIdToSelect integer ) 
begin
...

Here is the wrapper LLBLGen generates:


        public static int GetEmployeeIdWithNextException(System.String employeeIds, System.String exceptionIds, System.Int32 payPeriodId, System.Int32 companyId, ref System.Int32 empIdToSelect, DataAccessAdapter adapter)
        {
            SAParameter[] parameters = new SAParameter[5];
            parameters[0] = new SAParameter("@employeeIds", SADbType.LongVarchar, 32767, ParameterDirection.InputOutput, true, 0, 0, "",  DataRowVersion.Current, employeeIds);
            parameters[1] = new SAParameter("@exceptionIds", SADbType.LongVarchar, 32767, ParameterDirection.InputOutput, true, 0, 0, "",  DataRowVersion.Current, exceptionIds);
            parameters[2] = new SAParameter("@payPeriodId", SADbType.Integer, 4, ParameterDirection.InputOutput, true, 10, 0, "",  DataRowVersion.Current, payPeriodId);
            parameters[3] = new SAParameter("@companyId", SADbType.Integer, 4, ParameterDirection.InputOutput, true, 10, 0, "",  DataRowVersion.Current, companyId);
            parameters[4] = new SAParameter("@empIdToSelect", SADbType.Integer, 4, ParameterDirection.InputOutput, true, 10, 0, "",  DataRowVersion.Current, empIdToSelect);
            int toReturn = adapter.CallActionStoredProcedure("[DBA].[GetEmployeeIdWithNextException]", parameters);
            if(parameters[4].Value!=System.DBNull.Value)
            {
                empIdToSelect = (System.Int32)parameters[4].Value;
            }
            return toReturn;
        }

Any ideas as to why this is happening? Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 27-Jan-2010 15:55:27   

We're using run-time version 2.0.50727

That's not a correct runtime library build number, would you please follow this link to know how to get the RTL build/version number. ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725

one of our action stored procedures has been throwing a 'Specified Cast is not Valid' exception

Would you please post the complete excetion text and stack trace.

Posts: 8
Joined: 03-Sep-2009
# Posted on: 28-Jan-2010 18:34:33   

We are using File version: 2.6.9.616. Version 2.6 final (July 27th, 2009)

There is no additional exception text. The inner exception is null.

Here is the stack trace:

"

at iAnywhere.Data.SQLAnywhere.SACommand.ExecuteNonQuery()\r\n   at PayclockDAL.DatabaseSpecific.DataAccessAdapter.CallActionStoredProcedure(String storedProcedureToCall, SAParameter[] parameters) in C:\\Projects\\Team\\Lathem\\Trunk\\Source\\Payclock.Net\\Lathem.Payclock.DAL\\DatabaseSpecific\\DataAccessAdapter.cs:line 171\r\n   
at PayclockDAL.DatabaseSpecific.ActionProcedures.GetEmployeeIdWithNextException(String employeeIds, String exceptionIds, Int32 payPeriodId, Int32 companyId, Int32& empIdToSelect, DataAccessAdapter adapter) in C:\\Projects\\Team\\Lathem\\Trunk\\Source\\Payclock.Net\\Lathem.Payclock.DAL\\DatabaseSpecific\\ActionProcedures.cs:line 616\r\n   at Lathem.Payclock.DataAccess.DataProvider.GetEmployeeIdWithNextException(String employeeIds, String exceptionIds, Int32 payPeriodId, Int32 companyId, Int32& employeeToSelect) in C:\\Projects\\Team\\Lathem\\Trunk\\Source\\Payclock.Net\\Lathem.Payclock.DataAccess\\DataProvider.cs:line 3526\r\n   at Payclock.ucTimecard.nextExceptionButton_Click(Object sender, ClickEventArgs e) in C:\\Projects\\Team\\Lathem\\Trunk\\Source\\Payclock.Net\\Lathem.Payclock\\ucTimecard.cs:line 4988\r\n   at C1.Win.C1Command.C1Command.OnClick(ClickEventArgs e)\r\n   at C1.Win.C1Command.C1Command.Invoke(ClickEventArgs e)\r\n   at C1.Win.C1Command.bw.a(C1CommandLink A_0, a A_1)\r\n   at C1.Win.C1Command.bw.c(MouseEventArgs A_0)\r\n   at C1.Win.C1Command.MenuPopup.OnMouseUp(MouseEventArgs e)\r\n   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n   at System.Windows.Forms.Control.WndProc(Message& m)\r\n   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r\n   at System.Windows.Forms.ContainerControl.WndProc(Message& m)\r\n   at System.Windows.Forms.Form.WndProc(Message& m)\r\n   at C1.Win.C1Command.MenuPopup.WndProc(Message& m)\r\n   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)\r\n   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)\r\n   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n   at System.Windows.Forms.Application.Run(Form mainForm)\r\n   at Payclock.Program.Main() in C:\\Projects\\Team\\Lathem\\Trunk\\Source\\Payclock.Net\\Lathem.Payclock\\Program.cs:line 123\r\n   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"
MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 28-Jan-2010 22:47:07   

At which line exactly does the exception occur...?

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39865
Joined: 17-Aug-2003
# Posted on: 29-Jan-2010 10:50:00   

THe 'cast not valid' exception occurs inside the sybase code it seems as executenonquery is the method last called in the stacktrace you posted. Is there any 'inner' exception info? Could you also try the latest build for the ianywhere provider? Sybase fixed some of their bugs along the way, it might be that they fixed this one as well

Frans Bouma | Lead developer LLBLGen Pro