powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Хелп!
6 сообщений из 6, страница 1 из 1
Хелп!
    #32015641
Шура
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Есть такая процедура на SQL server'e
CREATE PROCEDURE sp_GetPath
@tcNumber varchar(9),
@tcRemark varchar(100),
@cPath varchar(250) OUTPUT
AS
select @cPath=path from otfvip where number = @tcNumber and remark = rtrim(@tcRemark)
как мне переменной в VB присвоить значение возвращаемое этой процедурой. Почему-то параметр OUTPUT при вызове этой процедуры предлагает ввести себя как INPUT параметр... ничво не понимаю.

помогите вызвать правильно процедуру. С утра мучаюсь... в форуме VB чё та молчат.
...
Рейтинг: 0 / 0
Хелп!
    #32015644
Glory
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
А как вы собственно запускаете данную процедуру на клиенте? Покажите ваш VB код с определением входных параметров и чтением выходных параметров.


PS
А знаете ли вы, что если присваивать результат выполнения процедуры с OUTPUT параметром в recordset, то само значание OUTPUT параметра на клиенте вы получите только после закрытия этого recordset-a
...
Рейтинг: 0 / 0
Хелп!
    #32015650
Шура
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
и не знаю чем будет являться результат выполнения этой процедуры - RecordSet или просто возвратит какое-то значение, кот. сразу можно положить в переменную или использовать как входящий параметр другой процедуры...

на SQL это выглядил так:

declare @cPath varchar(250)
select @cPath = ""
exec sp_getpath "OTF000131", "Информатика (для экономистов и менеджеров)", @cPath output
print @cPath

как переменной VB присвоить - вот это мне не ясно.
Объясните ламеру, заранее спасибо.
...
Рейтинг: 0 / 0
Хелп!
    #32015655
Glory
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
CREATE PROCEDURE myProc
@outparm int OUTPUT
@inparm int
AS
SELECT * FROM titles WHERE royalty > @inparm
SELECT @outparm = COUNT (*) FROM TITLES WHERE royalty > @inparm
IF (@outparm > 0)
RETURN 0
ELSE
RETURN 99
GO


An ADO code program that executes the stored procedure myProc is shown here.


Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim fldloop As ADODB.Field
Dim param1 As Parameter, param2 As Parameter, param3 As Parameter
Dim provStr As String
Dim royalty As Variant

Private Sub spStart()

' Connect using the SQLOLEDB provider.
cn.Provider = "sqloledb"

' Specify connection string on Open method.
provStr = "Server=MyServer;Database=pubs;Trusted_Connection=yes"
cn.Open provStr

' Set up a command object for the stored procedure.
Set cmd.ActiveConnection = cn
cmd.CommandText = "myProc"
cmd.CommandType = adCmdStoredProc

' Set up a return parameter.
Set param1 = cmd.CreateParameter("Return", adInteger, adParamReturnValue)
cmd.Parameters.Append param1

' Set up an output parameter.
Set param2 = cmd.CreateParameter("Output", adInteger, adParamOutput)
cmd.Parameters.Append param2

' Set up an input parameter.
Set param3 = cmd.CreateParameter("Input", adInteger, adParamInput)
cmd.Parameters.Append param3
royalty = Trim(InputBox("Enter royalty:"))
param3.Value = royalty

' Execute command, and loop through recordset, printing out rows.
Set rs = cmd.Execute

Dim i As Integer
While Not rs.EOF
For Each fldloop In rs.Fields
Debug.Print rs.Fields(i)
i = i + 1
Next fldloop
Debug.Print ""
i = 0
rs.MoveNext
Wend

' Need to close recordset before getting return
' and output parameters.
rs.Close

Debug.Print "Program ended with return code: " & Cmd(0)
Debug.Print "Total rows satisfying condition: " & Cmd(1)
cn.Close

End Sub


The following parameters are needed for the myProc stored procedure:

A return parameter to hold the return value (0 or 99).The return parameter is created as a return type of parameter adParamReturnValue, and the data type is adInteger for integer. Because the return parameter is the first parameter added to the collection, its index value is zero, and it can be dereferenced through that index (for example, as Cmd(0)).

An output parameter to hold the value of the count of the number of returned rows. The output parameter is created as adParamOuput for the output parameter type, and the data type is adInteger for integer. Because the output parameter is the second parameter added to the collection, its index value is 1, and it can be dereferenced through that index (for example, as Cmd(1)).

An input parameter, which holds the value of the user-supplied percent royalty number. The input parameter is created as adParamInput for the input parameter type, and the data type is adInteger for integer.
Because the data type of these stored procedure parameters is integer, there is no need to specify the data length as a parameter when defining them with the CreateParameter method.

After each parameter is added to the Parameters collection, executing the query string creates a recordset. After the recordset is closed, the values for the return code and output parameters are available.
...
Рейтинг: 0 / 0
Хелп!
    #32015659
Dmitriy
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
To Glory
А можно ссылочку на информацию о исползовании Stored Procedure в VB?
Это из MSDN ил нет?
...
Рейтинг: 0 / 0
Хелп!
    #32015660
Dmitriy
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
To Glory
Сорри сам нашел,RTFM
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Хелп!
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]