C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to grab UserId from ASPNET.db


Posted Date: 03 Oct 2006      Total Responses: 0

Posted By: rao mazin       Member Level: Bronze     Points: 2


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.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Post Reply
You must Sign In to post a response.
Next : Impressions in AdRotator Control
Previous : for access
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use