using Command to set Parameters and Recordset to retrive the Query

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default using Command to set Parameters and Recordset to retrive the Query

    Hi guys,

    withou using SP, I want to be able to add a Parameter to the SQL Query and
    retrive the Recordset so I can use the Paging property under the recorset
    object.... how can I do this?

    I'm stuck here.



    Set cnData = server.createObject("ADODB.Command")
    Set rsData = server.createObject("ADODB.RecordSet")
    ' set the page size
    rsData.PageSize = iPSize
    rsData.CursorLocation = adUseClient

    ' open the data
    sSQL = " SELECT * FROM vATSlistaAssistencias " & _
    " WHERE estado = 'ACTIVO' and estadoEsc not in ('FORA SERVICO', 'NAO
    QUER', 'NAO TEM MAQUINA', 'OUTRA 2') and " & _
    " idDistribuidorAssistencia = @idDistAss and localidade like @localidade
    " & _
    " ORDER BY @coluna @ordem"

    with cnData
    .ActiveConnection = sConnCW
    .CommandText = sSQL
    .CommandType = adCmdText

    .Parameters.Append = .CreateParameter("@idDistAss", adInteger,
    adParamInput)
    .Parameters.Append = .CreateParameter("@localidade", adVarChar,
    adParamInput, 100)
    .Parameters.Append = .CreateParameter("@coluna", adVarChar, adParamInput,
    100)
    .Parameters.Append = .CreateParameter("@ordem", adVarChar, adParamInput,
    5)

    .Parameters("@idDistAss") = idDistAssistencia
    .Parameters("@localidade") = sLocalidade
    .Parameters("@coluna") = sColuna
    .Parameters("@ordem") = sOrdem

    end with

    set rsData = cnData.execute
    cnData.ActiveConnection.Close


    I got an Error regarding the @idDistAss is not define in the query

    [Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable
    '@idDistAss'

    But, as you can see, I have it defined in the sSQL variable...

    What can I do? I'm really stuck here, please help mew



    --

    Bruno Miguel Alexandre
    Dep Informática do Grupo Filtrarte

    Av General Humberto Delgado, 91
    Vila Verde
    2705-887 Terrugem SNT
    Portugal

    T. +351 219 608 130
    F. +351 219 615 369
    w. [url]www.filtrarte.com[/url]
    @. [email]bruno@filtrarte.com[/email]




    Bruno Alexandre Guest

  2. Similar Questions and Discussions

    1. Command Object and RecordSet ASP
      I am very knew to asp and Im having problems returning the results from my stored procedure in the browser. The asp code and the html form code is...
    2. Too few parameters to RecordSet.Open?
      Hi All! My ASP page below receives the following error: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) Too few...
    3. SPs/Command Object/Parameters Problem
      I've searched through google groups and cannot find an answer to this: My application passes values from a form to a page that requests them and...
    4. Projector with command line parameters
      Hello, is it possible to build a projector, which can be started with command line parameters? If yes, how can I get access to this parameters...
    5. Command Parameters
      Can someone tell me why the following code does not work ? It does not crash or cause errors and it creates a new row in the table "tblusers" but...
  3. #2

    Default Re: using Command to set Parameters and Recordset to retrive the Query

    Bruno Alexandre wrote:
    > Hi guys,
    Already answered in .general.
    Please don't multipost. This question dealt with asp and databases so this
    was the perfect forum in which to post it. You gained nothing by posting it
    in .general as well (except wasting the time of myself and others who had to
    read this a second time). If anyone had taken their time and energy to
    answer the question here, only to find it had already been answered in the
    other newsgroup, they would have been sufficiently annoyed to at least
    consider ignoring any further posts from you. Post to ONE relevant
    newsgroup.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139