Home » RDBMS Server » Server Administration » ADO/Storeproc help needed.
ADO/Storeproc help needed. [message #374933] Thu, 12 July 2001 06:43
uttam das
Messages: 1
Registered: July 2001
Junior Member
Ello you wonderful people,
Its me first time in here so please help me out! :-p

Using ADO i'm trying to pick up the return value of my store procedure. The problem is in my VB code it always returns 0 regardless of whether there was an error in sp.
I have attached both my store procedure and VB code here: hope somebody can tell me what i'm doing wrong..

cheers in advance.

**********************
CREATE PROCEDURE dbo.sp_AddNewUser
-- add a new user
@userid varchar(30),
@password varchar(30)

AS
declare @error int

insert into
usertable ( userid,
passwords
)
values(@userid,
@password
)
select @error = @@ERROR

if @error != 0
begin
return @error
end
return 0
GO
******************
and this is my VB code

Dim oCmd As New adodb.Command
Dim oRs As New adodb.Recordset
Dim RetVal As Integer

With oCmd
.ActiveConnection = g_oConn
.CommandType = adCmdStoredProc
.CommandText = "sp_AddNewUser"
.Parameters.Refresh
.Parameters(1).Value = txtLoginID
.Parameters(2).Value = txtPassword
'Set oRs = .Execute
RetVal = .Parameters(0)
End With

'why does Retval always returns 0 ?!!!

Set oRs = Nothing
Set oCmd = Nothing
Previous Topic: It's not solved my problem :(
Next Topic: format date field
Goto Forum:
  


Current Time: Wed Jul 03 02:08:54 CDT 2024