MrMay
asked on
c# coding help
I need some help.
Can someone please take a look at the attached and please tell me what I need to adjust?
please & thank you.
This bit of code goes throught two access tables (inner joint) and returns the total number of hours worked by a mechanic
Capture.JPG
Can someone please take a look at the attached and please tell me what I need to adjust?
please & thank you.
This bit of code goes throught two access tables (inner joint) and returns the total number of hours worked by a mechanic
Capture.JPG
I removed my bad post. I had no way of deleting it.
Hi MrMay;
Try and placing everything after (int) in its own set of parentheses.
newNum1 = (int)( ... );
Try and placing everything after (int) in its own set of parentheses.
newNum1 = (int)( ... );
ASKER
I tried Fernando... no difference.
This code works if I replace SUM with COUNT in the sql query. But I don't want a count in this situation but a SUM.
This code works if I replace SUM with COUNT in the sql query. But I don't want a count in this situation but a SUM.
An index operation (i.e. the square brackets) has higher precedence than a cast (i.e. the (int) part), so you shouldn't need the additional parentheses that Fernando suggests...though adding them won't hurt anything. Are you certain that the think inside the column is actually of type int? Does the error go away if you change the code to use the Convert class instead?
e.g.
e.g.
newNum1 = Convert.ToInt32(ds.Tables["TaskLabor"].Rows[ds.Tables["TaskLabor"].Rows.Count - 1][0]);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the post kaufmed that worked. The only problem that I'm running into now is if there is a return of null (zero) I still get the same error msg.
So lets say hrs of Mechanic1 is 5.. i get that return. but lets say mechanicB has worked no hrs.. it crashes on me.
How do i adjust that so if there is a return of null (nothing) it returns a zero.
thank u all.
So lets say hrs of Mechanic1 is 5.. i get that return. but lets say mechanicB has worked no hrs.. it crashes on me.
How do i adjust that so if there is a return of null (nothing) it returns a zero.
thank u all.