This entry was posted on Monday, May 23rd, 2005 at 11:43 am and is filed under Uncategorized, Tech data. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.
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”)