Passing Parameters to a Stored Procedure using ASP

前端 未结 3 957
别跟我提以往
别跟我提以往 2020-11-30 15:53

I\'m trying to pass some parameters to a SQL stored procedure in my classic ASP. I\'ve seen several posts on this and not sure what I\'m doing wrong as I don\'t seem to see

3条回答
  •  难免孤独
    2020-11-30 16:19

    I think there is only a very small piece that you are doing wrong:

    set conn = CreateObject("ADODB.Connection") 
    conn.open ("DSN=SERVER;UID=username;PWD=pwd;Database=MyDatabase")
    
    set cmd = Server.CreateObject("ADODB.Command")
    set cmd.ActiveConnection = conn
    cmd.CommandType = 4 ' adCmdStoredProc constant is not defined in your context
    cmd.CommandText = my_proc
    cmd.Parameters.Refresh
    cmd.Parameters(1).value = "MyParam"
    
    set rs = cmd.execute
    

    The ADO constants are probably undefined, and also (but not sure) the parameter should be assign via its value property.

提交回复
热议问题