Link to home
Start Free TrialLog in
Avatar of Cashmgmt
Cashmgmt

asked on

Nested if else statements giving error

I have the following nested if else statement and it keeps giving me the error that it has an illefal else without matching if .  I've tried playing with the brackets and can't get it to work.  Can someone point out where the problem is?  Thanks in advance!
if (!bEndOfDay)
	{
		if (!MoveData(csTblName, csBlobTable, csBulkTable,pSqlDb))
		{
			update_detail("Error in moving data from ....");
			uRetVal = FALSE;
		}
		else
		{
			if (g_SysCfg.IsVerbose())
				update_detail("Data moved from to .....");
		}
	}
	else
	{
		if (!MoveBulkData(csBulkTable,pSqlDb))
		{
			update_detail("Error in moving data from ....");
			uRetVal = FALSE;
		}
		else
		{
			if (g_SysCfg.IsVerbose())
				update_detail("Data moved from to .....");
		}
	}
	else
	{
		if (!MoveAlertData(csAPAlertTable,pSqlDb))
		{
			update_detail("Error in moving data from ....");
			uRetVal = FALSE;
		}
		else
		{
			if (g_SysCfg.IsVerbose())
				update_detail("Data moved from to .....");
		}
	}
	return uRetVal;

Open in new window

Avatar of jkr
jkr
Flag of Germany image

Well, take a look at your code, there's indeed one 'else' that has no 'if':
if (!bEndOfDay)
        {
                if (!MoveData(csTblName, csBlobTable, csBulkTable,pSqlDb))
                {
                        update_detail("Error in moving data from ....");
                        uRetVal = FALSE;
                }
                else
                {
                        if (g_SysCfg.IsVerbose())
                                update_detail("Data moved from to .....");
                }
        }
        else
        {
                if (!MoveBulkData(csBulkTable,pSqlDb))
                {
                        update_detail("Error in moving data from ....");
                        uRetVal = FALSE;
                }
                else
                {
                        if (g_SysCfg.IsVerbose())
                                update_detail("Data moved from to .....");
                }
        } // <---------- if (!bEndOfDay) ends here
 
        else // <----------- there's no if for that one
        {
                if (!MoveAlertData(csAPAlertTable,pSqlDb))
                {
                        update_detail("Error in moving data from ....");
                        uRetVal = FALSE;
                }
                else
                {
                        if (g_SysCfg.IsVerbose())
                                update_detail("Data moved from to .....");
                }
        }
        return uRetVal;

Open in new window

Avatar of Cashmgmt
Cashmgmt

ASKER

Yeah, I see it and that's where the program is stopping when I try to build, but I'm new to programming and I can't figure out how to make the else that's causing the error part of the if (!bEndOfDay).  can you help?
Well, that's pretty hard, since that's not a complete function and I have no idea what it is supposed to do ;o)

Well, is 'MoveAlertData()' supposed to execute when 'bEndOfDay' is 'true' or 'false' or under what other condition?
if bEndOfDay is false, then i need it to do the MoveDate then MoveBulkDate then MoveAlertData
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're absolutely right.  So obvious and I didn't see it.  Thanks, that worked!!!