Hi; Can someone kindly help me to solve this problem?
I have a database called Dictionary Databse which contains two tables Terms (TermId, UserId, Term) Definitions(DefinitionId, UserId, TermId,Meaning,MeaningDetails,Example,CategoryName,TypeName); each term has many definitions submitted by different users through an ASP.NET 2.0 page. called submition page. To access this page users need to login. when i added the login control asp.net automatically generated aspnet.db , i have moved all the tables and stored procedure of aspnet.db into Dictionary databse by generating their script and run it on Dictionary databse. Now i want a when a user login grab his/her UserId and inserted into Terms and TermProperty Table if he/she submitted any term.
I am using this stored procedure to add a new term or a definition which works fine if i provide the UserId manually.
ALTER PROCEDURE dbo.AddTerm ( @Term nvarchar (100), @UserId int, @Meaning nvarchar(max), @MeaningDetails nvarchar(max), @Example nvarchar(max), @CategoryName nvarchar(50), @TypeName nvarchar(50) ) AS DECLARE @TermIdentity INT, @id INT IF EXISTS(SELECT 'True' FROM Terms WHERE Term = @Term) BEGIN
--This means the term already exist . SELECT 'This term already exists!. Therefore only the meaning has been added' SELECT @id=( SELECT TermID AS id FROM Terms WHERE Term=@Term) INSERT INTO Definitions (TermID,UserId,Meaning,MeaningDetails, Example,CategoryName,TypeName)
VALUES (@id,@UserId,@Meaning,@MeaningDetails, @Example,@CategoryName,@TypeName ) END ELSE BEGIN SET NOCOUNT ON; --This means the term isn't in there already, let's go ahead and add it SELECT 'Term Added'
INSERT INTO Terms (Term, UserId) VALUES (@Term,@UserId) SET @TermIdentity=@@Identity
INSERT INTO Definitions (TermID,UserId,Meaning,MeaningDetails, Example,CategoryName,TypeName)
VALUES (@TermIdentity,@UserId,@Meaning,@MeaningDetails, @Example,@CategoryName,@TypeName )
END
I have tried a lot i have not been able to sort this i would realy apritiate is any one could show me hot to do that.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|