I am learning how to write stored procedure. Now I got a question .
in VB6 I create a stored Procedure
Here is my code
strsql = "create procedure USP_Getmaxsequence" & _
"(@MaxsequenceNo Nvarchar output) as " & _
"select @MaxsequenceNO=max(right(SEQUCENO,5)) from mytable"
Set Cmd = CreateObject("adodb.command")
.ActiveConnection = ocnn
.CommandText = strsql
It exist in the Stored procedure list.
Now I call USP_Getmaxsequence:
.CommandText = "USP_Getmaxsequence"
.CommandType = adCmdStoredProc
Set param = Ocmd.CreateParameter("ReturnValue", adInteger, adParamReturnValue, 0)
Set param = Ocmd.CreateParameter("MaxsequenceNo", adVarChar, adParamOutput, 1)
I got the output value (Ocmd.Parameters(1).Value) is "0", not the right value.
if I directly use "sql"(select max(right(SEQUCENO,5)) from mytable) In vb6, the result is right, like "00037"
anybody knows how to write this simple stored procedure to get the right result. such as 2000001,1000002, I need to get "00002".
Note the at-sign.
Set param = Ocmd.CreateParameter("@MaxsequenceNo", adVarChar, adParamOutput, 1)
If you hit a brick wall, you didn't jump high enough!
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL