Storing return value of a Stored Proc in a Session

R

raghav

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
 
D

donet programmer

what exactly are you trying to achieve?? can you post some sample
code...???
 
R

raghav

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,Email,Mobile,ResumePath,DoB)
Values(@FirstName,@MiddleName,@LastName,@Gender,@Email,@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,ApplicantID)
values(@Hobbies,@Interests,@Achievements,@ApplicantID)


end

ELSE

INSERT INTO
Applicant(FirstName,MiddleName,LastName,DoB,Gender,Email,Mobile,ResumePath)
Values(@FirstName,@MiddleName,@LastName,@DoB,@Gender,@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,@Phonep,@IsPermanentAddress,@ApplicantID)

insert into PersonalDetails(Hobbies,Interests,Achievements,ApplicantID)
values(@Hobbies,@Interests,@Achievements,@ApplicantID)
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 said:
what exactly are you trying to achieve?? can you post some sample
code...???
raghav said:
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
 
D

donet programmer

hope this provides some help ..
http://aspnet.4guysfromrolla.com/articles/062905-1.aspx
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,Email,Mobile,ResumePath,DoB)
Values(@FirstName,@MiddleName,@LastName,@Gender,@Email,@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,ApplicantID)
values(@Hobbies,@Interests,@Achievements,@ApplicantID)


end

ELSE

INSERT INTO
Applicant(FirstName,MiddleName,LastName,DoB,Gender,Email,Mobile,ResumePath)
Values(@FirstName,@MiddleName,@LastName,@DoB,@Gender,@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,@Phonep,@IsPermanentAddress,@ApplicantID)

insert into PersonalDetails(Hobbies,Interests,Achievements,ApplicantID)
values(@Hobbies,@Interests,@Achievements,@ApplicantID)
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 said:
what exactly are you trying to achieve?? can you post some sample
code...???
raghav said:
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
 
R

raghav

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 said:
hope this provides some help ..
http://aspnet.4guysfromrolla.com/articles/062905-1.aspx
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,Email,Mobile,ResumePath,DoB)
Values(@FirstName,@MiddleName,@LastName,@Gender,@Email,@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,ApplicantID)
values(@Hobbies,@Interests,@Achievements,@ApplicantID)


end

ELSE

INSERT INTO
Applicant(FirstName,MiddleName,LastName,DoB,Gender,Email,Mobile,ResumePath)
Values(@FirstName,@MiddleName,@LastName,@DoB,@Gender,@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,@Phonep,@IsPermanentAddress,@ApplicantID)

insert into PersonalDetails(Hobbies,Interests,Achievements,ApplicantID)
values(@Hobbies,@Interests,@Achievements,@ApplicantID)
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top