Hi,
I need to insert a new row in a table and get the newly created rowid at the same time.
I have this SPROC:
==============
USE [dnn520]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Questions_Add]
(@Q_Text ntext)
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [dbo].[Questions]
(Q_Text)
VALUES
(@Q_Text)
-- Get the newly created rowID
SELECT cast(SCOPE_IDENTITY() as int) AS newQID
END
==============
newQID is the new rowID.
This works in mssql studio and when I run the SPROC it inserts the new row and displays the new rowID.
Now I need to set the procedure that handles this in DataProvider.vb, AddQController.vb and SqlDataProvider.vb to do the insert and getting the rowID at the same query to the DB.
I use these code snippets:
in DataProvider.vb:
...
Public MustOverride Sub Questions_Add(ByVal Q_Text As String)
...
In SqlDataProvider.vb :
...
Public Overrides Sub Questions_Add(ByVal Q_Text As String)
SqlHelper.ExecuteNonQuery(ConnectionString, GetFullyQualifiedName("Questions_Add"), Q_Text)
End Sub
...
in PsychoAddQController.vb:
Public Sub Questions_Add(ByVal objQuestions_Add As AddQInfo)
DataProvider.Instance().Questions_Add(objQuestions_Add.Q_Text)
End Sub
...
How do I do this?
Thanks,
Yehuda