script

  • Consider the following snippet of ASP script:

     

    Set oConn = CreateObject("ADODB.Connection")

    oConn.Open "MyDatabaseConnectionString"

    departmentId = Request.QueryString("deptId")

    sSql = "SELECT * FROM Employees" _

           & "WHERE department_id=" & departmentId _

           & "ORDER BY last_name, first_name"

    Set oRs = oConn.Execute(sSql)

     

    What issues exist in the above code?  Consider both coding syntax as well as best practices.

  • ...

    sSql = "EXEC dbo.DepartmentEmployees " _

    & "@department_id = " & departmentId

    Set oRs = oConn.Execute(sSql)

    _____________
    Code for TallyGenerator

  • Considering your other post... this looks a lot like a take-home exam...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply