?
Solved

unexpected error in C# asp.net - conversion error

Posted on 2010-08-19
8
Medium Priority
?
1,948 Views
Last Modified: 2013-12-17

Hi group,

I'm having a question about a situation I have run into .... on one hand I have a pre-written code in C# and on other hand it talks to an old database (DB2). I'm asked to fix it!
now, I have the error message and finally after hours asking here and there I was able to get access to a machine to see the code.

The funny part is that code works but sometimes it throws the error in following. At the same time I noticed this error happens (NOT SURE 100%) when few people working on database (directly).

Can somebody tell me by looking at code  what is causing this? I understand there is a conversion error. Also, I was told that DBA has changed new field into table so the order of fields is changed.

I'm not sure if order matters. any idea?

Thanks,
ak



A conversion error occurred.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: IBM.Data.DB2.iSeries.iDB2ConversionException: A conversion error occurred.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[iDB2ConversionException: A conversion error occurred.]
   AppCenter.Models.UserRepository.Get(String key) in C:\Projects\AppCenter\AppCenter\Models\UserRepository.cs:148
   AppCenter.Controllers.AccountController.Login(String userName, String password, Boolean rememberMe, String returnUrl) in C:\Projects\AppCenter\AppCenter\Controllers\AccountController.cs:80
   lambda_method(ExecutionScope , ControllerBase , Object[] ) +245
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
   System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7() +52
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254
   System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +399
   System.Web.Mvc.Controller.ExecuteCore() +126
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +27
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
   System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +151
   System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
   System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Open in new window

0
Comment
Question by:akohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:gmarino
ID: 33481879
You don't give much to work with. There is not enough information in the error to diagnose the problem.

"DBA has changed new field into table so the order of fields is changed."  <<-- This could pose a problem IF the C# code uses SELECT *  instead of listing out the specific column names.  Check the code for SELECT * FROM.

- Greg
0
 

Author Comment

by:akohan
ID: 33481927

Hi Greg,

I will look at it further, it is just I was given the task today. it is like asking you to fix a bug when you have no idea yet what the code is doing or even where it is located

Sure but you are right I saw few queries with * rather than specifing fields name. Things like:  SELECT  *  FROM tbl_xyz and ....

thanks,
ak
0
 
LVL 14

Assisted Solution

by:raja_ind82
raja_ind82 earned 400 total points
ID: 33482081
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 37

Expert Comment

by:momi_sabag
ID: 33483252
since it sometime work and sometimes not, this is a data error
i guess you have some issue with the dates format in your input
0
 

Author Comment

by:akohan
ID: 33485543

Gmarino,

Are you saying I have to change * to fields one by one in SELECT statements? if so, then why * causing the issue?

0
 
LVL 4

Accepted Solution

by:
gmarino earned 600 total points
ID: 33486820
ak,

I'm not saying it IS causing the issue.  Rather I am just fishing for possible problems.

You stated "that DBA has changed new field into table so the order of fields is changed."

When using SELECT * FROM table, the columns are presented in the order they exist in the table.  If someone changes the order of the columns in the table AND (here's the key) you are binding those columns to variables or an array in the C# code, then Column_C which used to be bound to Variable_C could now be bound to a different variable.

Old Table Layout
Column_A
Column_B
Column_C

Select *...into Var_A,Var_B,Var_C  returns
Var_A=Column_A
Var_B=Column_B
Var_C=Column_C


New Table Layout
Column_A
Column_C
Column_B
 
Select *...into Var_A,Var_B,Var_C  returns
Var_A=Column_A
Var_B=Column_C (!!!!!)
Var_C=Column_B (!!!!!)

which could lead to a conversion error.

There - that should make it as clear as mud!  :-)


-Greg
0
 

Author Comment

by:akohan
ID: 33503482

thanks to all.

regards,
ak
0
 

Author Closing Comment

by:akohan
ID: 33503488
Thanks
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question