How to write an IF clause within a C# application for a Windows platform using VS2005?

I am developing a C# application using VS2005 in a Windows platorm with SQL Server as the back end database.

In the following snippet of code, I wish to evaluate a string named "cycle"

If cycle = "fall" then the FROM clause of the SQL statement should state:
FROM [tblFlLNMod$]", conn);

Else                         the FROM clause of the SQL statement should state:
FROM [tblSpLNMod$",conn);

How would you perform the IF test for the 2 forms of the SQL ... FROM clause
in the following context?

========================================

DataTable sourceData = new DataTable();

            using (OleDbConnection conn = new OleDbConnection(sourceConnString))
            {
                conn.Open();

                OleDbCommand command = new OleDbCommand(

                         @"SELECT [CPS 1st First Name],
                                  [CPS 1st Mid],
                                  [CPS 1st Last Name],
                                  [CPS 2nd First Name],
                                  [CPS 2nd Mid],
                                  [CPS 2nd Last Name],
                                  [CPS Address 1],
                                  [CPS Address 2],
                                  [CPS City],
                                  [CPS State],
                                  [CPS Zip],
                                  [CPS SSN/Tax ID],
                                  [CPS Account Number],
                                  [FA Number],
                                  [CPS Date Of Birth],
                                  [LEXIS NEXIS 1st First Name],
                                  [LEXIS NEXIS 1st Mid],
                                  [LEXIS NEXIS 1st Last Name],
                                  [LEXIS NEXIS Address],
                                  [LEXIS NEXIS City],
                                  [LEXIS NEXIS State],
                                  [LEXIS NEXIS Zip],
                                  [LEXIS NEXIS Phone],
                                  [Escheat Y/N]            
                           FROM [tblSpLNMod$]", conn);

                OleDbDataAdapter adapter = new OleDbDataAdapter(command);

                adapter.Fill(sourceData);

                conn.Close();
zimmer9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anurag ThakurTechnical ManagerCommented:
do like this

OleDbCommand command = new OleDbCommand(
       "SELECT
          [CPS 1st First Name],
              [CPS 1st Mid],
          [CPS 1st Last Name],
          [CPS 2nd First Name],
          [CPS 2nd Mid],
          [CPS 2nd Last Name],
          [CPS Address 1],
          [CPS Address 2],
          [CPS City],
          [CPS State],
          [CPS Zip],
          [CPS SSN/Tax ID],
          [CPS Account Number],
          [FA Number],
          [CPS Date Of Birth],
          [LEXIS NEXIS 1st First Name],
          [LEXIS NEXIS 1st Mid],
          [LEXIS NEXIS 1st Last Name],
          [LEXIS NEXIS Address],
          [LEXIS NEXIS City],
          [LEXIS NEXIS State],
          [LEXIS NEXIS Zip],
          [LEXIS NEXIS Phone],
          [Escheat Y/N]  
         FROM "
+ cycle == "fall" ? "[tblFlLNMod$]" : "[tblSpLNMod$]" , conn);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AyyappanRdknCommented:
DataTable sourceData = new DataTable();

            using (OleDbConnection conn = new OleDbConnection(sourceConnString))
            {
                conn.Open();

                OleDbCommand command = new OleDbCommand(

                         @"SELECT [CPS 1st First Name],
                                  [CPS 1st Mid],
                                  [CPS 1st Last Name],
                                  [CPS 2nd First Name],
                                  [CPS 2nd Mid],
                                  [CPS 2nd Last Name],
                                  [CPS Address 1],
                                  [CPS Address 2],
                                  [CPS City],
                                  [CPS State],
                                  [CPS Zip],
                                  [CPS SSN/Tax ID],
                                  [CPS Account Number],
                                  [FA Number],
                                  [CPS Date Of Birth],
                                  [LEXIS NEXIS 1st First Name],
                                  [LEXIS NEXIS 1st Mid],
                                  [LEXIS NEXIS 1st Last Name],
                                  [LEXIS NEXIS Address],
                                  [LEXIS NEXIS City],
                                  [LEXIS NEXIS State],
                                  [LEXIS NEXIS Zip],
                                  [LEXIS NEXIS Phone],
                                  [Escheat Y/N]            
                           FROM" + cycle == "fall" ? "[tblFlLNMod$]" : "[tblSpLNMod$]" , conn);

                OleDbDataAdapter adapter = new OleDbDataAdapter(command);

                adapter.Fill(sourceData);

                conn.Close();
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.