Monday, 9 July 2012

check if a string contains small letter in sql


select patindex('%[a-z]%'    COLLATE Latin1_General_BIN,'test')

select patindex( '%es%'    COLLATE Latin1_General_BIN,'Test')

Sunday, 8 July 2012

sql - Check length of a string


Length of VARCHAR fields the function LEN(varcharfield) is useful.
Length of TEXT fields the function is DATALENGTH(textfield). Len will not work for text field.
Example:
SELECT LEN(yourvarcharfield) AS VarcharFieldSize
SELECT DATALENGTH(yourtextfield) AS TEXTFieldSize

SQL - check if a string has uppercase / lowercase characters


DECLARE @myString NVARCHAR(200) -- The length of the NVARCHAR is mandatory, otherwise it is not clear why but it is not working
SET @myString = 'ExTremeDev.blogSpot.com23'

IF @myString = LOWER(@myString) COLLATE Latin1_General_CS_AI
BEGIN
  PRINT '- The string must contain at least one uppercase character.'
END

IF @myString = UPPER(@myString) COLLATE Latin1_General_CS_AI
BEGIN
  PRINT '- The string must contain at least one lowercase character.'
END

IF PATINDEX('%[0-9]%',@myString) = 0
BEGIN
  PRINT '- The string must contain at least one numeric character.'
END

Thursday, 5 July 2012

Channel timeout exception


Notice that you do not call close on the proxy - this means that the service will be maintaining a session on behalf of the client (assuming you are using broadly the default settings of the WSHttpBinding)

add a call to requestClient.Close() after calling the Execute operation

Wednesday, 4 July 2012

Count No of users- session Count -global.asax



    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        Application["count"] = 0;
    }
   
    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown
        Application["count"] = (int)Application["count"] - 1;
    }
       

Sunday, 1 July 2012

highlight-words-jquery-ui-autocomplete and catcomplete

<script type="text/javascript">
    $("#textbox").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "search.php",
                dataType: "json",
                data: request,
                success: function (data) {

                    var regex = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi");
                    var result = $.map(data, function (value) {
                        return value.replace(regex, "<b>$1</b>");
                    });
                    response(result);
                }
            });
        }
    });
</script>