|
-
Aug 6th, 2003, 05:41 AM
#1
Thread Starter
New Member
Stored Procedure
Hi
The code below seems to fail on Executing the query!
Any ideas?
Gary
SP:
CREATE PROCEDURE [spInsertOrder]
(@customerID int,
@theidentity int OUTPUT
)
AS
INSERT INTO [costingSystem].[dbo].[Orders]
( [customerID],
[dateOrdered])
VALUES
( @customerID,
getdate())
Select theidentity = @@identity
GO
CODE:
Dim prmCustomerID As New SqlParameter()
Dim prmTheIdentity As New SqlParameter()
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor()
objConn = New SqlConnection(myGlobals.Name())
objConn.Open()
Try
With prmCustomerID
.Direction = ParameterDirection.Input
.SqlDbType = SqlDbType.Int
.ParameterName = "@customerID"
.Value = cbCustomerID.Text
End With
With prmTheIdentity
.Direction = ParameterDirection.Output
.SqlDbType = SqlDbType.Int
.ParameterName = "@theIdentity"
End With
objCmd = New SqlCommand("spInsertOrder", objConn)
With objCmd
.Parameters.Add(prmCustomerID)
.Parameters.Add(prmTheIdentity)
.ExecuteNonQuery()
End With
MessageBox.Show("The newest Identity value is: " & prmTheIdentity.Value.ToString)
Catch sqlEx As SqlException
MessageBox.Show(sqlEx.ToString)
Finally
objConn.Close()
objConn.Dispose()
End Try
Me.Cursor = System.Windows.Forms.Cursors.Default()
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
|