English 中文(简体)
将存储程序与VB 文本中的产出参数联系起来
原标题:Calling SQL Stored Procedure with Output Parameter in VBScript

我写了VB文本的功能,要求采用储存程序。 过去,我撰写了一些职能,要求有投入参数的储存程序,但在这种情况下,我需要与一个产出参数合作。

在另一项申请中,我称“实体框架”所储存的程序完全相同,因此所储存的程序是罚款的。

我的守则如下:

Function checkAccess(userid,link)
    isAllowed = false

    set cmd = Server.CreateObject("ADODB.Command")
    cmd.CommandText = "Check_Permission"
    cmd.ActiveConnection = Conn
    cmd.NamedParameters = true
    cmd.CommandType = adCmdStoredProc
    cmd.Parameters.Append(cmd.CreateParameter("@Login", adVarChar, adParamInput, 50, userId))
    cmd.Parameters.Append(cmd.CreateParameter("@LinkId", adInteger, adParamInput, 50, link))    
    cmd.Parameters.Append(cmd.CreateParameter("@IsAllowed", adBoolean, adParamOutput, 10, isAllowed))

    checkAccess = isAllowed
End Function

这一职能总是虚假的。 我怎么做?

最佳回答

您应退还产出参数的价值:

checkAccess = cmd.Parameters("@IsAllowed").Value

此外,ADO的输出参数不需要初步值,而Boolean的参数不需要一定规模,因此,你可以改变最后一段:

cmd.Parameters.Append(cmd.CreateParameter("@IsAllowed", adBoolean, adParamOutput))

你们也可以摆脱低劣的变量,因为不再需要。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签