S
scparker
Hello,
We have a stored procedure that does a basic insert of values. I am
then able to retrieve the ID number created for this new record. We are
currently using ASP.NET 2.0 and use N-Tier Architecture.
The Stored Procedures are used through TableAdaptors, which in turn are
used by Class Files.
I wish to be able to return this new ID value using the Stored
Procedure, TableAdaptor and for it to be available in the Class file.
At present we are unable to get this working. Does anybody have
experience of getting this method of operation working at all?
An Example Stored Procedure:
--------------------------------------------
CREATE PROCEDURE [dbo].[InsertSupplier]
(
@Company nvarchar(1000),
@SupplierId int OUTPUT
)
AS
BEGIN
/* Insert Supplier */
INSERT INTO Supplier (Company)
VALUES (@Company)
/* Retrieve Supplier Id */
SET @SupplierId=@@IDENTITY
END
GO
--------------------------------------------
An Example Portion of The Class (VB.NET 2.0):
--------------------------------------------
'*** Create New Supplier
Public Function CreateSupplier( _
ByVal Company As String, _
ByVal SupplierId As Integer) As Boolean
'*** Declare Variables
Dim Result As Boolean
'*** Insert Supplier
Result = Adapter.Insert(Company, SupplierId)
'*** Publish Result
Return Result
End Function
--------------------------------------------
As you can see from the class, this deals wwith actually enterting the
values into the stored procedure, which will then add it into the table
itself. How would I be able to represent the returning value in this
portion of the class?
I would like to be able to do this without having to do another call to
the database. I come from ASP 3.0 (Classic) background and am used to
using Stored Procedures with Command objects that will allow the
returning of values. I have as yet, been unable to simulate such
operations using ASP.NET 2.0 and am looking for help with this
situation.
Anyone have any ideas, solutions?
Sincerely,
SP
We have a stored procedure that does a basic insert of values. I am
then able to retrieve the ID number created for this new record. We are
currently using ASP.NET 2.0 and use N-Tier Architecture.
The Stored Procedures are used through TableAdaptors, which in turn are
used by Class Files.
I wish to be able to return this new ID value using the Stored
Procedure, TableAdaptor and for it to be available in the Class file.
At present we are unable to get this working. Does anybody have
experience of getting this method of operation working at all?
An Example Stored Procedure:
--------------------------------------------
CREATE PROCEDURE [dbo].[InsertSupplier]
(
@Company nvarchar(1000),
@SupplierId int OUTPUT
)
AS
BEGIN
/* Insert Supplier */
INSERT INTO Supplier (Company)
VALUES (@Company)
/* Retrieve Supplier Id */
SET @SupplierId=@@IDENTITY
END
GO
--------------------------------------------
An Example Portion of The Class (VB.NET 2.0):
--------------------------------------------
'*** Create New Supplier
Public Function CreateSupplier( _
ByVal Company As String, _
ByVal SupplierId As Integer) As Boolean
'*** Declare Variables
Dim Result As Boolean
'*** Insert Supplier
Result = Adapter.Insert(Company, SupplierId)
'*** Publish Result
Return Result
End Function
--------------------------------------------
As you can see from the class, this deals wwith actually enterting the
values into the stored procedure, which will then add it into the table
itself. How would I be able to represent the returning value in this
portion of the class?
I would like to be able to do this without having to do another call to
the database. I come from ASP 3.0 (Classic) background and am used to
using Stored Procedures with Command objects that will allow the
returning of values. I have as yet, been unable to simulate such
operations using ASP.NET 2.0 and am looking for help with this
situation.
Anyone have any ideas, solutions?
Sincerely,
SP