Custom error pages and WCF exceptions in IIS, and a case of bad UI

retno:

I have this issue and so far it helps.

Originally posted on Enough Blogging!:

Nope, nothing to do with Haskell.

This admittedly boring post is about two specific problems with IIS 7.5 and WCF which wasted so much of my time that I thought it would be worth to  document them.

If you have a WCF service hosted as an ASP.NET application in IIS, you may encounter the following exception on the client side:

System.ServiceModel.ProtocolException: The content type text/html of the response message does not match the content type of the binding (application/x-gzip). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 75 bytes of the response were: ‘The page cannot be displayed because an internal server error has occurred.’.

—> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
— End of inner exception stack trace —

The system I’m maintaining has gzip-binary-encoded data over HTTP, so the first…

View original 743 more words

Mencari nilai suatu field dalam database di semua table

Query berikut ini berfungsi untuk mencari nilai suatu field dalam database, menggunakan “like”, dan pencariannya melingkupi seluruh table yang ada dalam database tersebut.

Misalnya kita ingin mencari nilai “Retno” dalam database “HR”, tetapi kita tidak tau table mana yang digunakan. Buka editor query baru, paste query di bawah ini, ganti “Retno” dengan nilai yang ingin dicari.

DECLARE @Results TABLE(ColumnName nvarchar(370), ColumnValue nvarchar(3630), TableName nvarchar(255))

SET NOCOUNT ON

DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
SET  @TableName = ''
SET @SearchStr2 = QUOTENAME('%Retno%','''')

WHILE @TableName IS NOT NULL
BEGIN
    SET @ColumnName = ''
    SET @TableName = 
    (
        SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
        FROM    INFORMATION_SCHEMA.TABLES
        WHERE       TABLE_TYPE = 'BASE TABLE'
            AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
            AND OBJECTPROPERTY(
                    OBJECT_ID(
                        QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                         ), 'IsMSShipped'
                           ) = 0
    )

    WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)
    BEGIN
        SET @ColumnName =
        (
            SELECT MIN(QUOTENAME(COLUMN_NAME))
            FROM    INFORMATION_SCHEMA.COLUMNS
            WHERE       TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                AND TABLE_NAME  = PARSENAME(@TableName, 1)
                AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
                AND QUOTENAME(COLUMN_NAME) > @ColumnName
        )

        IF @ColumnName IS NOT NULL
        BEGIN
            INSERT INTO @Results
            EXEC
            (
                'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630), ''' + @TableName + ''' 
                FROM ' + @TableName + ' (NOLOCK) ' +
                ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
            )
        END
    END 
END

SELECT ColumnName, ColumnValue FROM @Results

Cara Supaya Text Bisa Diklik Di Radio Button

Ketika kita membuat radio button di web, default-nya text di sebelah radio button itu tidak bisa diklik, tidak sinkron dengan radio button-nya.

Contoh penggunaannya adalah aplikasi kuis. Cara supaya text itu berkoresponden terhadap radio button yang kita buat, gunakan skrip berikut ini:

<form>
    <p>What is my middle name?</p>
    <br>
    <input id="349" type="radio" value="1" name="question1">
    <label for="349">Abe</label>
    <br>
    <input id="350" type="radio" value="2" name="question1">
    <label for="350">Andrew</label>
    <br>
    <input id="351" type="radio" value="3" name="question1">
    <label for="351">Andre</label>
    <br>
    <input id="352" type="radio" value="4" name="question1">
    <label for="352">Anderson</label>
    <br>
</form>

sedangkan demo-nya bisa dilihat di sini.

Put arrow in proper dropdown and unicode

So, I’m working on web application project for media advertisement online. I design the layout from the zero, and the first problem I met was… how to put arrow in proper dropdown, which has the sub menu.

this link will help:

http://jsfiddle.net/w9xnv/2/

and some webicon:

http://www.goetter.fr/unicode/

and to design footer, so it keeps on the bottom:

http://www.cssreset.com/demos/layouts/how-to-keep-footer-at-bottom-of-page-with-css/

SQL SERVER – Simple Example of WHILE Loop With CONTINUE and BREAK Keywords

retno:

I’ll need it someday, may be. good article :)

Originally posted on Journey to SQL Authority with Pinal Dave:

This is question is one of those question which is very simple and most of the users get it correct, however few users find it confusing for first time. I have tried to explain the usage of simple WHILE loop in first example. BREAK keyword will exit the stop the while loop and control is moved to next statement after the while loop. CONTINUE keyword skips all the statement after its execution and control is sent to first statement of while loop. Run following examples in Query Editor and see the result. This is very easy to understand example.

1) Example of WHILE Loop
DECLARE @intFlag INT
SET
@intFlag = 1
WHILE (@intFlag <=5)
BEGIN
PRINT
@intFlag
SET @intFlag = @intFlag + 1
END
GO

ResultSet:
1
2
3
4
5

2) Example of WHILE Loop with BREAK keyword
DECLARE @intFlag INT
SET
@intFlag = 1
WHILE

View original 86 more words

Cara Membuat Autonumber di SQLServer 2008

format yang diinginkan adalah CTC00001, untuk membuat autonumber di SQLServer2008 bisa dicoba alternatif kode berikut:

declare @houseno varchar (20); 

SELECT @houseno = 'CTC' + substring(convert(varchar, cast(max(substring(HOUSE_NO,4,5))+1 as float)/100000), 3,7)
FROM CONTOHTABEL;

Karena contoh di atas menggunakan store procedure, maka untuk input datanya seperti:

INSERT INTO CONTOHTABEL (HOUSE_NO) 
	VALUES (@houseno);