Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Storing return value of a Stored Proc in a Session

Reply
Thread Tools

Storing return value of a Stored Proc in a Session

 
 
raghav
Guest
Posts: n/a
 
      11-02-2006
Hi all
I am having a SP which is returning a value......Now I have to store
that value

in session...I saw some examples in msdn lib ---->
string Name=string.Empty;
Session["Raghav"]=Name.ToString();


But in my case return value is ID ...and it has not been declared in C#

code as Name is declared in Above exapmle...bec i am not inserting that

ID from front end....
So what will be the C# code to store value returned from SP in a
session?I posted this query in other group also but no good
response....Looking for further responses...
--Raghav

 
Reply With Quote
 
 
 
 
donet programmer
Guest
Posts: n/a
 
      11-02-2006
what exactly are you trying to achieve?? can you post some sample
code...???
raghav wrote:
> Hi all
> I am having a SP which is returning a value......Now I have to store
> that value
>
> in session...I saw some examples in msdn lib ---->
> string Name=string.Empty;
> Session["Raghav"]=Name.ToString();
>
>
> But in my case return value is ID ...and it has not been declared in C#
>
> code as Name is declared in Above exapmle...bec i am not inserting that
>
> ID from front end....
> So what will be the C# code to store value returned from SP in a
> session?I posted this query in other group also but no good
> response....Looking for further responses...
> --Raghav


 
Reply With Quote
 
 
 
 
raghav
Guest
Posts: n/a
 
      11-02-2006
Hi
See, I want to store a value returned from Stored Proc in a session
using C#...Yes I will post code------

ALTER PROCEDURE Applicant1
@FirstName char(20),
@MiddleName char(20),
@LastName char(20),
@DoB Datetime,
@Gender Char(10),
@Email varchar(20),
@Mobile numeric(12,0),
@ResumePath varchar(MAX),
@Address varchar(MAX),
@City char(30),
@State int,
@Country int,
@Pin numeric(10,0),
@phone numeric(15,0),
@Addressp varchar(MAX),
@Cityp char(30),
@Statep int,
@Countryp int,
@Pinp numeric(10,0),
@phonep numeric(15,0),
@Hobbies varchar(250),
@Interests varchar(250),
@Achievements varchar(250),
@IsPermanentAddress bit,
@ApplicantID int output

AS
SET NOCOUNT ON

IF @IsPermanentAddress = 0

begin

INSERT INTO
Applicant(FirstName,MiddleName,LastName,Gender,Ema il,Mobile,ResumePath,DoB)
Values(@FirstName,@MiddleName,@LastName,@Gender,@E mail,@Mobile,@ResumePath,@DoB)

select @ApplicantID = @@Identity

insert into
ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
values(@Address,@City,@State,@Country,@Pin,@Phone, @IsPermanentAddress,@ApplicantID)

insert into PersonalDetails(Hobbies,Interests,Achievements,App licantID)
values(@Hobbies,@Interests,@Achievements,@Applican tID)


end

ELSE

INSERT INTO
Applicant(FirstName,MiddleName,LastName,DoB,Gender ,Email,Mobile,ResumePath)
Values(@FirstName,@MiddleName,@LastName,@DoB,@Gend er,@Email,@Mobile,@ResumePath)

select @ApplicantID = @@Identity

insert into
ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
values(@Address,@City,@State,@Country,@Pin,@Phone, @IsPermanentAddress,@ApplicantID)

insert into
ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
values(@Addressp,@Cityp,@Statep,@Countryp,@Pinp,@P honep,@IsPermanentAddress,@ApplicantID)

insert into PersonalDetails(Hobbies,Interests,Achievements,App licantID)
values(@Hobbies,@Interests,@Achievements,@Applican tID)
RETURN @ApplicantID
--------------------------------------------------------------------------------------------------------------------------------
This SP is returning ApplicantID.I have to store this ID in a session,
Then I will pass that value in other SP.So just I want to know that How
I can store this value in session..ApplicantID is not inserted from
front end, It just exists in Database....
Hope u understood what I exactly want...
Regards
Raghav..

donet programmer wrote:
> what exactly are you trying to achieve?? can you post some sample
> code...???
> raghav wrote:
> > Hi all
> > I am having a SP which is returning a value......Now I have to store
> > that value
> >
> > in session...I saw some examples in msdn lib ---->
> > string Name=string.Empty;
> > Session["Raghav"]=Name.ToString();
> >
> >
> > But in my case return value is ID ...and it has not been declared in C#
> >
> > code as Name is declared in Above exapmle...bec i am not inserting that
> >
> > ID from front end....
> > So what will be the C# code to store value returned from SP in a
> > session?I posted this query in other group also but no good
> > response....Looking for further responses...
> > --Raghav


 
Reply With Quote
 
donet programmer
Guest
Posts: n/a
 
      11-02-2006
hope this provides some help ..
http://aspnet.4guysfromrolla.com/articles/062905-1.aspx

raghav wrote:
> Hi
> See, I want to store a value returned from Stored Proc in a session
> using C#...Yes I will post code------
>
> ALTER PROCEDURE Applicant1
> @FirstName char(20),
> @MiddleName char(20),
> @LastName char(20),
> @DoB Datetime,
> @Gender Char(10),
> @Email varchar(20),
> @Mobile numeric(12,0),
> @ResumePath varchar(MAX),
> @Address varchar(MAX),
> @City char(30),
> @State int,
> @Country int,
> @Pin numeric(10,0),
> @phone numeric(15,0),
> @Addressp varchar(MAX),
> @Cityp char(30),
> @Statep int,
> @Countryp int,
> @Pinp numeric(10,0),
> @phonep numeric(15,0),
> @Hobbies varchar(250),
> @Interests varchar(250),
> @Achievements varchar(250),
> @IsPermanentAddress bit,
> @ApplicantID int output
>
> AS
> SET NOCOUNT ON
>
> IF @IsPermanentAddress = 0
>
> begin
>
> INSERT INTO
> Applicant(FirstName,MiddleName,LastName,Gender,Ema il,Mobile,ResumePath,DoB)
> Values(@FirstName,@MiddleName,@LastName,@Gender,@E mail,@Mobile,@ResumePath,@DoB)
>
> select @ApplicantID = @@Identity
>
> insert into
> ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
> values(@Address,@City,@State,@Country,@Pin,@Phone, @IsPermanentAddress,@ApplicantID)
>
> insert into PersonalDetails(Hobbies,Interests,Achievements,App licantID)
> values(@Hobbies,@Interests,@Achievements,@Applican tID)
>
>
> end
>
> ELSE
>
> INSERT INTO
> Applicant(FirstName,MiddleName,LastName,DoB,Gender ,Email,Mobile,ResumePath)
> Values(@FirstName,@MiddleName,@LastName,@DoB,@Gend er,@Email,@Mobile,@ResumePath)
>
> select @ApplicantID = @@Identity
>
> insert into
> ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
> values(@Address,@City,@State,@Country,@Pin,@Phone, @IsPermanentAddress,@ApplicantID)
>
> insert into
> ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
> values(@Addressp,@Cityp,@Statep,@Countryp,@Pinp,@P honep,@IsPermanentAddress,@ApplicantID)
>
> insert into PersonalDetails(Hobbies,Interests,Achievements,App licantID)
> values(@Hobbies,@Interests,@Achievements,@Applican tID)
> RETURN @ApplicantID
> --------------------------------------------------------------------------------------------------------------------------------
> This SP is returning ApplicantID.I have to store this ID in a session,
> Then I will pass that value in other SP.So just I want to know that How
> I can store this value in session..ApplicantID is not inserted from
> front end, It just exists in Database....
> Hope u understood what I exactly want...
> Regards
> Raghav..
>
> donet programmer wrote:
> > what exactly are you trying to achieve?? can you post some sample
> > code...???
> > raghav wrote:
> > > Hi all
> > > I am having a SP which is returning a value......Now I have to store
> > > that value
> > >
> > > in session...I saw some examples in msdn lib ---->
> > > string Name=string.Empty;
> > > Session["Raghav"]=Name.ToString();
> > >
> > >
> > > But in my case return value is ID ...and it has not been declared in C#
> > >
> > > code as Name is declared in Above exapmle...bec i am not inserting that
> > >
> > > ID from front end....
> > > So what will be the C# code to store value returned from SP in a
> > > session?I posted this query in other group also but no good
> > > response....Looking for further responses...
> > > --Raghav


 
Reply With Quote
 
raghav
Guest
Posts: n/a
 
      11-03-2006
Hi
This link is giving information about returning value from a stored
procedure. This was not my question. I want to know that how I can
store that value returned from SP in a session in page behind using C#
2005.
--Raghav
donet programmer wrote:
> hope this provides some help ..
> http://aspnet.4guysfromrolla.com/articles/062905-1.aspx
>
> raghav wrote:
> > Hi
> > See, I want to store a value returned from Stored Proc in a session
> > using C#...Yes I will post code------
> >
> > ALTER PROCEDURE Applicant1
> > @FirstName char(20),
> > @MiddleName char(20),
> > @LastName char(20),
> > @DoB Datetime,
> > @Gender Char(10),
> > @Email varchar(20),
> > @Mobile numeric(12,0),
> > @ResumePath varchar(MAX),
> > @Address varchar(MAX),
> > @City char(30),
> > @State int,
> > @Country int,
> > @Pin numeric(10,0),
> > @phone numeric(15,0),
> > @Addressp varchar(MAX),
> > @Cityp char(30),
> > @Statep int,
> > @Countryp int,
> > @Pinp numeric(10,0),
> > @phonep numeric(15,0),
> > @Hobbies varchar(250),
> > @Interests varchar(250),
> > @Achievements varchar(250),
> > @IsPermanentAddress bit,
> > @ApplicantID int output
> >
> > AS
> > SET NOCOUNT ON
> >
> > IF @IsPermanentAddress = 0
> >
> > begin
> >
> > INSERT INTO
> > Applicant(FirstName,MiddleName,LastName,Gender,Ema il,Mobile,ResumePath,DoB)
> > Values(@FirstName,@MiddleName,@LastName,@Gender,@E mail,@Mobile,@ResumePath,@DoB)
> >
> > select @ApplicantID = @@Identity
> >
> > insert into
> > ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
> > values(@Address,@City,@State,@Country,@Pin,@Phone, @IsPermanentAddress,@ApplicantID)
> >
> > insert into PersonalDetails(Hobbies,Interests,Achievements,App licantID)
> > values(@Hobbies,@Interests,@Achievements,@Applican tID)
> >
> >
> > end
> >
> > ELSE
> >
> > INSERT INTO
> > Applicant(FirstName,MiddleName,LastName,DoB,Gender ,Email,Mobile,ResumePath)
> > Values(@FirstName,@MiddleName,@LastName,@DoB,@Gend er,@Email,@Mobile,@ResumePath)
> >
> > select @ApplicantID = @@Identity
> >
> > insert into
> > ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
> > values(@Address,@City,@State,@Country,@Pin,@Phone, @IsPermanentAddress,@ApplicantID)
> >
> > insert into
> > ContactDetails(Address,City,StateID,CountryID,Pin, Phone,IsPermanentAddress,ApplicantID)
> > values(@Addressp,@Cityp,@Statep,@Countryp,@Pinp,@P honep,@IsPermanentAddress,@ApplicantID)
> >
> > insert into PersonalDetails(Hobbies,Interests,Achievements,App licantID)
> > values(@Hobbies,@Interests,@Achievements,@Applican tID)
> > RETURN @ApplicantID
> > --------------------------------------------------------------------------------------------------------------------------------
> > This SP is returning ApplicantID.I have to store this ID in a session,
> > Then I will pass that value in other SP.So just I want to know that How
> > I can store this value in session..ApplicantID is not inserted from
> > front end, It just exists in Database....
> > Hope u understood what I exactly want...
> > Regards
> > Raghav..
> >
> > donet programmer wrote:
> > > what exactly are you trying to achieve?? can you post some sample
> > > code...???
> > > raghav wrote:
> > > > Hi all
> > > > I am having a SP which is returning a value......Now I have to store
> > > > that value
> > > >
> > > > in session...I saw some examples in msdn lib ---->
> > > > string Name=string.Empty;
> > > > Session["Raghav"]=Name.ToString();
> > > >
> > > >
> > > > But in my case return value is ID ...and it has not been declared in C#
> > > >
> > > > code as Name is declared in Above exapmle...bec i am not inserting that
> > > >
> > > > ID from front end....
> > > > So what will be the C# code to store value returned from SP in a
> > > > session?I posted this query in other group also but no good
> > > > response....Looking for further responses...
> > > > --Raghav


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i retrieve a Return Value (0 or 1) from my stored proc? Learner ASP .Net 4 12-22-2005 07:59 AM
Convert VB.NET to TSQL PROC & Reference a Proc from another Proc David Lozzi ASP .Net 3 06-01-2005 06:35 PM
return value from stored proc using MS Data Access Application Block hansiman ASP .Net 0 02-05-2005 05:59 PM
SQL Stored Proc - ASP Page - Return Value Scott ASP General 11 04-12-2004 11:00 AM
how to return multiple values from stored proc? smen ASP .Net 3 01-09-2004 03:50 PM



Advertisments