IdleTymes Blog

Personal Diary, Musing and rubish of a F*!^%#g bored programmer.

CREATE PROCEDURE usp_MyTest
@UserName varchar(200) AS

BEGIN
INSERT INTO users (UserName) VALUES (@UserName)

RETURN @@IDENTITY
END

Now, we create an ADO command object to access this stored procedure;

Dim aCmd as New ADODB.Command

` We assume that aConn - a connection to the SQL DB - is already open

aCmd.ActiveConnection = aConn
aCmd.CommandText = “usp_MyTest”
aCmd.CommandType = adCmdStoredProc

` add the parameters:
` strCustName is a string variable with the customer name in it

aCmd.Parameters.Append aCmd.CreateParameter(”CustName”, adVarChar, adParamInput, 200, strCustName)

aCmd.Parameters.Append aCmd.CreateParameter(”Identity”, adInteger, adParamReturnValue)

aCmd.Execute

NewID = aCmd.Parameters(”Identity”)


Comments are closed.