By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,494 Members | 1,502 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,494 IT Pros & Developers. It's quick & easy.

Storing return value of a Stored Proc in a Session

P: n/a
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

Nov 2 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Nov 2 '06 #2

P: n/a
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
Nov 2 '06 #3

P: n/a
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
Nov 2 '06 #4

P: n/a
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
Nov 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.