473,412 Members | 4,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Storing return value of a Stored Proc in a Session

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
4 2038
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jason Collins | last post by:
There are a number of stored procedures involved in sql server based session maintenance: - TempUpdateStateItemShort - TempResetTimeout - TempUpdateStateItemLong etc. These stored procs are...
2
by: jakk | last post by:
Iam storing the session state in SQL Server. The Session gets stored in the SQL Server temp tables ( I can see some values in the two tables), but the session doesnt seem to timeout. We have a...
12
by: Alex D. | last post by:
is it possible? pros and cons?
4
by: Learner | last post by:
Hi there, I have a storec proc that schedules a Sql job and finally it returns 0 then it was successfull and if it returns 1 then its unsuccessful. Now when i run the stored proc in the query...
2
by: philip | last post by:
hello, i am new to asp.net and sql server, and i have 3 questions for asking: 1. i am writing a store procedure of login validation for my asp.net application and wondering what the different...
1
by: Eric Effer | last post by:
Hi I am a newbie with vb.net. I am working with vb.net 2.0 and sql server 2005. I am trying to get the return value from my insert stored proc.Does anyone know how to do this? thanks E
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
2
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I can successfully insert and update the oracle database by calling a oracles stored proc from my .net code. This oracle stored proc is returning some value. I cannot see that...
8
by: colmkav | last post by:
Can someone tell me how I can access the return value of a function called from Oracle as opposed to a store proc from oracle? my oracle function is get_num_dates_varposfile. I am only used to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.