Click here to Skip to main content
15,171,576 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Dear All,
Please convert this to SQL STATEMENT.

C#
if (NoOFAttempts) < maxCaptcha)
        {
       message.Text = " NoOFAttempts is Less Than maxCaptcha";

        }
        else if (NoOFAttempts == maxCaptcha)
        {
            message.Text = "" NoOFAttempts is Equal maxCaptcha ";
        }
        else if (NoOFAttempts > maxCaptcha)
        {

            if (Convert.ToInt32(NoOFAttempts > maxLock)
            {
               
            message.Text = "" NoOFAttempts is greater than maxLock ";

                
            }
            else
            {
            message.Text = "" NoOFAttempts is Less  than maxLock ";
            }
        }
Posted
Updated 29-Jul-13 20:36pm
v2
Comments
Ankur\m/ 30-Jul-13 1:37am
   
Why do you think we will do your work? What have you tried? Show us your efforts and where you failed and we will try to help you out with it.
Thanks7872 30-Jul-13 1:49am
   
I do not find anything that needs to be converted into SQL. And also 'TRY' should be from your side,not from ours. We are here to help you,not to code for you.
[no name] 30-Jul-13 3:12am
   
My suggestion to use the "Resharper" that will be more useful for you to optimize the code that you were trying here.

1 solution

It should be something like that:
SQL
SELECT CASE WHEN NoOFAttempts < maxCaptcha THEN 'NoOFAttempts is Less Than maxCaptcha'
            WHEN NoOFAttempts == maxCaptcha THEN 'NoOFAttempts is Equal maxCaptcha'
            WHEN NoOFAttempts > maxCaptcha 'NoOFAttempts is greater than maxLock' END AS [Message]
FROM ...
   
Comments
[no name] 30-Jul-13 3:16am
   
@Maciej Los,

I think here the enquirer had this question to optimize the code. Its nicely done by you for the conversion of the code, But still I feel its a bad idea to hit the DB for such a code. Instead we can optimize the code using the "Resharper" in a better way.

Thanks
Maciej Los 30-Jul-13 3:23am
   
Thank you for your comment. If i'm not wrong, OP wants to convert code from C# to SQL. There is not enough information to guess what OP want to achieve at all. Maybe, using C# code it would be better, maybe not ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900