Click here to Skip to main content
15,887,383 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
in one page i have saved the details of an student and in second page i have to store the extra details of that person how it is possible all the details should be saved in one row only.
Posted
Comments
Nandakishore G N 18-Jan-13 2:08am    
in first page insert the values in the second page just update it with the same id..

You will create the record in first page. After creating, return the record key to the application from database. This key should be used in second page to just update the existing record.
 
Share this answer
 
can u share me the code how to update based on the id
 
Share this answer
 
Change your stored procedure and return the newly inserted record from it. If your table uses identity use:
SQL
Create Procedure InsertDetails
(
@name varchar(50),
@telephone varchar(15)
)
AS
BEGIN
insert into YourTableName
values
@name, @telephone
select scope_identity() as result
END

if you are passing record id manually use:
SQL
Create Procedure InsertDetails
(
@id varchar(10),
@name varchar(50),
@telephone varchar(15)
)
AS
BEGIN
insert into YourTableName
values
@name, @telephone
select @id as result
END


Now, in your code behind use:
C#
string _userID = com.ExecuteScalar().ToString();

After this use either:
C#
Response.Redirect("UpdateDetails.aspx?id="_userID);

or
C#
Session["userID"] = _userID;
Response.Redirect("UpdateDetails.aspx")


On UpdateDetails.aspx get the user id either from session or querystring. Now you can update the details using the user id.
 
Share this answer
 
Comments
Dhritirao's 18-Jan-13 4:07am    
thanku
Zafar Sultan 18-Jan-13 4:16am    
Did it work for u?
Hi dear,

Even i faced the same problem, you can get a lot of help from the below code...

Check once and let me know,


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[RegisterDetails]
(
@statecode varchar(2),
@districtCode varchar(2),
@TPAID varchar(2),
@IC varchar(2),
@HospitalCode varchar(MAX),
@AuthorityID varchar(8),
@HospitalName varchar(MAX),
@HospitalType bit,
@AcknowLetter bit,
@KeyActDate varchar(max),
@InstallDate varchar(max),
@InstalledBy Varchar(MAX),
@KitStatus bit,
@PaymentStatus bit,
@ReceivedAmt varchar(MAX),
@ModeOfPayment varchar(MAX),
@PaymentDetails Varchar(MAX)

)
as begin

begin Transaction

declare @AuthoId varchar(8)
if not exists(select * from HospitalDetails where AuthorityID=@AuthorityID)
Begin

Insert into HospitalDetails([HospitalCode],[HospitalName],[AuthorityID],[StateCode],[DistrictCode],
[TPAId],[InsuranceCode],[HospitalType]) values(@HospitalCode,@HospitalName,@AuthorityID,@statecode,
@districtCode,@TPAID,@IC,@HospitalType)
end

select @AuthoId=AuthorityID from HospitalDetails where HospitalCode=@HospitalCode
if not exists (select * from InstallationDetails where AuthorityID=@AuthoId )
begin

Insert into InstallationDetails([AuthorityID],[HospitalCode],[KeyActivationDate],[InstallationDate],[InstalledBy],[KitStatus])
values(@AuthorityID,@HospitalCode,@KeyActDate,@InstallDate,@InstalledBy,@KitStatus)
end

select @AuthoId=AuthorityId from PaymentDetails where HospitalCode=@HospitalCode
if not exists(select * from PaymentDetails where AuthorityId=@AuthoId)
begin

Insert into PaymentDetails([AuthorityId],[HospitalCode],[PaymentStatus],[ModeOfPayment],[ReceivedAmount],[PaymentDetails],[AcknowledgementLetter])
Values(@AuthorityID,@HospitalCode,@PaymentStatus,@ModeOfPayment,@ReceivedAmt,@PaymentDetails,@AcknowLetter)
end

if @@ERROR<>0
begin
rollback transaction
return 1
end
else
begin
commit transaction
return 0
end
end


















SQL

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900