Conditional Order By for stored procedure

    Date: 11/04/05 (Web Development)    Keywords: asp, sql, web

    ORDER BY CASE WHEN @OrderBy = '1' THEN NEWID()
    WHEN @OrderBy = '2' THEN (tblaccommodation.name)
    WHEN @OrderBy = '3' THEN (tblaccommodation.FromDT)
    END

    This is the order by conditional statement i am using
    to order an asp.net result set but it keeps returning
    this error below for the name feild (text) and sql
    server throws up a unique identifier error for FromDT
    (a datetime) which asks for the convert fuction to be
    used but each of these three works without the Case
    statement without any trouble.

    The asp.net error for name feild
    Syntax error converting from a character string to uniqueidentifier.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Syntax error converting from a character string to uniqueidentifier.

    Source Error:

    Line 220: ' Create and Fill the DataSet
    Line 221: Dim myDataSet As New DataSet()
    Line 222: myCommand.Fill(myDataSet)
    Line 223:
    Line 224: ' Return the DataSet

    Source: http://www.livejournal.com/community/webdev/265072.html

« Resolutions, and not the... || possible web design business? »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home