Solved

Nested if else statements giving error

Posted on 2009-04-15
6
544 Views
Last Modified: 2013-12-14
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

0
Comment
Question by:Cashmgmt
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 24149528
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

0
 

Author Comment

by:Cashmgmt
ID: 24149846
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?
0
 
LVL 86

Expert Comment

by:jkr
ID: 24150075
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?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Cashmgmt
ID: 24150098
if bEndOfDay is false, then i need it to do the MoveDate then MoveBulkDate then MoveAlertData
0
 
LVL 86

Accepted Solution

by:
jkr earned 250 total points
ID: 24150121
Then, you don't need ansy 'else' for 'if (!bEndOfDay)':
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 .....");

                }

        

                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 (!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

0
 

Author Closing Comment

by:Cashmgmt
ID: 31570530
You're absolutely right.  So obvious and I didn't see it.  Thanks, that worked!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio Debugging 3 121
eclipse luna javeEE perspecive missing 5 97
Visual studio sees sql server but cannot connect 7 60
Use tracing facilities in your browser steps 2 110
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now