Help: stored procedure getting executed twice

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

  1. #1

    Default Help: stored procedure getting executed twice

    I am having a problem where a SQL Server stored procedure is being
    executed twice by a single cal in an ASP page (Windows 2000).

    I run this in Visual InterDev, and verified that the .Execute step
    is not happenning twice. I put a statement in the stored procedure
    to write the params and timestamp to a log file every time it executes,
    and can see this it is happening twice.

    This is my first real experience with ASP, so hopefully it is something
    simple.

    tia,
    Bill


    The ASP code looks like:

    Cnxn.Open strCnxn

    If Request.QueryString("mode")="AddUser" Then
    If (Trim(Request.Form("txtUserName"))) = "" Then
    strError = "Error: Username must be entered"
    ElseIf (Trim(Request.Form("txtPassword")) = "") Then
    strError = "Error: Password must be entered"
    Else
    If Cnxn.State = adStateOpen Then
    txtUserName = LCase(Trim(Request.Form("txtUserName")))
    txtPassword = Trim(Request.Form("txtPassword"))
    txtFirstName = Trim(Request.Form("txtFirstName"))
    txtLastName = Trim(Request.Form("txtLastName"))

    Set cmdAddUser = Server.CreateObject("ADODB.Command")
    Set rsAddResult = Server.CreateObject("ADODB.Recordset")

    With cmdAddUser
    .ActiveConnection = Cnxn
    .CommandText = "dmsAddUser"
    .CommandType = adCmdStoredProc

    .Parameters.Append .CreateParameter("@RETURN_VALUE", adInteger,
    adParamReturnValue)
    .Parameters.Append .CreateParameter("@userName", adVarChar,
    adParamInput, 15)
    .Parameters.Append .CreateParameter("@userPWD", adVarChar,
    adParamInput, 15)
    .Parameters.Append .CreateParameter("@lname", adVarChar,
    adParamInput, 20)
    .Parameters.Append .CreateParameter("@fname", adVarChar,
    adParamInput, 20)
    .Parameters.Append .CreateParameter("@errMsg", adVarChar,
    adParamInputOutput, 50)

    .Parameters("@userName") = txtUserName
    .Parameters("@userPWD") = txtPassword
    .Parameters("@lname") = txtLastName
    .Parameters("@fname") = txtFirstName
    .Parameters("@errMsg") = ""

    Set rsAddResult = .Execute
    If rsAddResult.Open Then
    rsAddResult.Close
    End If

    strError = .Parameters("@errMsg")
    End With

    Set cmdAddUser = Nothing
    Set rsAddResult = Nothing
    Bill S. Guest

  2. Similar Questions and Discussions

    1. Stored Procedure
      EXEC master..xp_cmdshell 'cscript c:\path\file.vbs' EXEC master..xp_cmdshell 'c:\path\file.exe' "Kannan" <gk_i@yahoo.com> wrote in message...
    2. stored procedure help
      Hi all! I am in need of writing a few stored procedures. The first one is to create a stored procedure to recover a database from backup and the...
    3. stored procedure value
      How can I bind a stored procedure value to a page? I've executed a stored procedure and there should be two column values created...i.e. col1 and...
    4. help with a stored procedure
      I am new to postgres stored procedures and would like a little help. My function basically takes 2 arguments and inserts data into a table from a...
    5. Stored procedure from stored procedure
      Is it possible to create a stored procedure from a stored procedure? When I attempt this inanity, it doesn't blow up until syntax error at the...
  3. #2

    Default Re: stored procedure getting executed twice

    Bill S. wrote:
    > Set rsAddResult = .Execute
    > If rsAddResult.Open Then
    > rsAddResult.Close
    > End If
    Here's your problem right here. Your stored procedure does not return
    records. Why on earth would you create a recordset to execute the procedure?
    Simply do this:

    ..Execute ,,128
    strError = .Parameters("@errMsg")


    The 128 is the value of the adExecuteNoRecords constant. You should tell ADO
    not to bother creating a recordset object to retrieve the results of this
    stored procedure.

    HTH,
    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