The code belows shows how u can access your stored procedures from vb6.
In the example i use an input and output parameter so it is possible to select, update, insert data into the MS SQL 2000 database.
Stored procedure
CREATE Procedure MyStoredProcdure
(@ID integer,
@Description varchar(100) output
)
AS
select @Description = Description
from dbo.MNZ_FOTO
WHERE ID = @ID
GO
vb code
On Error GoTo ErrHandler
Set cn = New ADODB.Connection
cn.ConnectionString = Session.GetConnectionstring
cn.OpenSet cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = “MyStoredProcdure”
cmd.Parameters.Append cmd.CreateParameter(”ID”, adInteger, adParamInput, , 614)
cmd.Parameters.Append cmd.CreateParameter(”Description”, adVarChar, adParamOutput, 100)
cmd.ExecuteMsgBox cmd.Parameters(1).Value
Set cmd = Nothing
Set cn = Nothing
Exit Function
ErrHandler:
MsgBox Err.Description
Set cmd = Nothing
Set cn = Nothing
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Nov | ||||||
| 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 | |
RSS feed for comments on this post · TrackBack URI
Leave a reply