472,983 Members | 2,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 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 2016
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.