|
-
Mar 29th, 2002, 02:21 PM
#1
Thread Starter
Addicted Member
Stored Procedure Problem
Here is my stored procedure code
CREATE PROCEDURE [sp_NewImport] (@Responder_1 [nvarchar](16)) AS
DECLARE @NewNo AS int
DECLARE @MaxID AS char(6)
DECLARE @NewTransferID AS char(6)
SET @MaxID = (SELECT MAX(TransferID) FROM tblImportTransfers)
IF @MaxID IS NULL
SET @NewNo = 1
ELSE
SET @NewNo = CAST(RIGHT(@MaxID, LEN(@MaxID) - 1) AS int) + 1
SET @NewTransferID = CAST(@NewNo AS char(6))
WHILE LEN(@NewTransferID) < 5
SET @NewTransferID = '0' + @NewTransferID
SET @NewTransferID = 'T' + @NewTransferID
INSERT INTO [smile].[dbo].[tblImportTransfers] ([TransferID], [LastUpdate], [TransferDate], [Responder])
VALUES (@NewTransferID, GETDATE(), GETDATE(), @Responder_1)
SELECT @NewTransferID AS TransferID
GO
Here is my application code (VB6)
Public Function NewImport() As String
Dim cnTemp As ADODB.Connection
Set cnTemp = New ADODB.Connection
With cnTemp
.Open g_strConn
.BeginTrans
NewImport = .Execute("EXEC sp_NewImport '" & g_Username & "'")!TransferID
.CommitTrans
.Close
End With
Set cnTemp = Nothing
End Function
After I run this function I got message ""Item cannot be found in the collection carresponding to the requestd name or ordinal. Why the stored procedure did not return the value to VB? In Query Analyzer I got value and field name that I have specified. How can I correct this error?
Thank You,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|