Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6233305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:16:32+00:00 2026-05-24T10:16:32+00:00

HiI am trying to attach the where clause to sql statement like this public

  • 0

HiI am trying to attach the where clause to sql statement like this

    public static DataTable paymentType(string paymenttype, string ddproviders, string overdue)
    { 

                string paymenttypestr = "";
    string ddproviderstr = "";


    if (paymenttype != "")
    {
        paymenttypestr = string.Format("AND membertomships.memberToMship_PayMethod = '{0}'", paymenttype);        

    }
    if (ddproviders != "")
    {
        ddproviderstr = string.Format("AND ddproviders.ddProvider_Name = '{0}'", ddproviders);

    }
    if (overdue == "OverDue-Now")
    { 
       string sql += @"WHERE memberpaysched.memberPaySched_dateDue < NOW() AND memberpaysched.memberPaySched_amountDue > memberpaysched.memberPaySched_amountPaid ";

    }

    string  sql = string.Format(
                @"SELECT    members.member_Id,
                   members.member_Lastname As Last_name,
                   members.member_Firstname AS First_name,
                   members.member_PostCode  As Post_Code, 
                   ddaccounts.ddAccount_DdReference As dd_reference,
                   ddproviders.ddProvider_Name As dd_providername,
                   memberToMship_ChargePerPeriod As monthly_amount,
                   mshiptypes.mshipType_Name As Membership_type,
                   mshipstatustypes.mshipStatusType_Name As Status,
                   membertomships.memberToMship_EndDate As Expiry_Date,
                   membertomships.memberToMship_PayMethod As payment_method
                   FROM members 
                   LEFT JOIN membertomships ON membertomships.member_Id = members.member_Id
                   LEFT JOIN memberpaysched ON memberpaysched.memberPaySched_memberId = members.member_Id
                   LEFT OUTER JOIN ddaccounts ON ddaccounts.member_Id = members.member_Id
                   LEFT OUTER JOIN  ddproviders ON  ddaccounts.ddProvider_Id=ddproviders.ddProvider_Id 
                   LEFT JOIN   mshipstatustypes ON mshipstatustypes.mshipStatusType_Id = membertomships.mshipStatusType_Id
                   LEFT JOIN   mshipoptions ON mshipoptions.mshipOption_Id = membertomships.mshipOption_Id
                   LEFT JOIN   mshiptypes ON mshiptypes.mshipType_Id = mshipoptions.mshipType_Id
                   WHERE       members.member_Active LIKE 'y%'
                   AND               mshipoptions.mshipOption_Period = 'month' 
                   AND               (mshipstatustypes.mshipStatusType_Id <> 5)
                   {0}
                   {1}     
                   ORDER BY members.member_Lastname",
                   paymenttypestr, ddproviderstr);
      return getdata(sql,mf);
    }

but it was giving error at this line like “;” this symbol is needed;

    string sql += @"WHERE memberpaysched.memberPaySched_dateDue < NOW() AND memberpaysched.memberPaySched_amountDue > memberpaysched.memberPaySched_amountPaid "; 

I want to add this where clause if overdue == “overdue-now”

how can i add this where clause according to condition

would any one help on this ….

Modified Query :   string sql += @"memberpaysched.memberPaySched_dateDue < NOW() AND memberpaysched.memberPaySched_amountDue > memberpaysched.memberPaySched_amountPaid";

still it was showing this error
“Invalid EXPRESSION TERM +=”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:16:33+00:00Added an answer on May 24, 2026 at 10:16 am

    I’m no .NET expert, but I’d probably change:

    if (overdue == "OverDue-Now")     
    {
         string sql += @"WHERE memberpaysched.memberPaySched_dateDue < NOW() AND memberpaysched.memberPaySched_amountDue > memberpaysched.memberPaySched_amountPaid ";      
    } 
    

    to:

    if (overdue == "OverDue-Now")     
    {
         sql += @"AND memberpaysched.memberPaySched_dateDue < NOW() AND   memberpaysched.memberPaySched_amountDue > memberpaysched.memberPaySched_amountPaid ";      
    } 
    

    (i.e. remove the string keyword, and substitute AND for WHERE)

    and put it AFTER the main SQL block (i.e. where you’re declaring your string sql variable)..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hii... I have a function something like this... class Zend_View_Helper_RenderUOList extends Zend_View_Helper_Abstract { public
hi i am trying to create a URL that looks like this: black/granite/worktops where
Hi I trying do something like that: I've got some string - 'Hello World!'
I have a situation like this, Iam trying to select a label using Id
Hi I'm trying to debug a stored procedure through SQL Analyzer and one of
Hi I am trying to learn Linq, so I am not sure if this
Hii , I have been trying to write a program... We have a structure
Hi I am trying to read xml string and trying to replace from old
Hi I'm trying to write a regex statement to match a { character only
Hi I am trying to delete an HTML tag from a string. The tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.