私は登録フォームを持っており、その後、ユーザーIDに基づいて最初のページに必須フィールドを挿入しています。下の2ページ目の詳細を更新しています。これが私のコードです。
ALTER procedure [dbo].[Insertreg]
( @id int output,@FirstName varchar (50),@LastName varchar(50) ,@Dob datetime,
@Gender varchar(20) ,@MobileNo nchar(10) ,@Country varchar(50) ,
@State varchar (50),@EmailId varchar (50),@Password nchar (15)
)
as
begin
insert into Profile_Master(FirstName,LastName,Dob,Gender,MobileNo,Country,State,EmailId,Password)
values
(@FirstName,@LastName,@Dob,@Gender,@MobileNo,@Country,@State,@EmailId,@Password)
set @id=SCOPE_IDENTITY()
end
ALTER procedure [dbo].[sp_update]
(@id int output,@FormFiledBy varchar (50),@MaritalStatus varchar (50),@Height varchar (50),
@Religion varchar (50),@Caste varchar (100),
@MotherTongue varchar(50),@Education varchar (100),@Occupation varchar(50),
@CountryofResidence varchar (50),@EducationDetails varchar (100),@AnnualIncome varchar(50),
@CountryOfBirth varchar(50),@BirthPlace varchar(50),@TimeOfBirth nchar(10),@StarSign varchar (100),
@Gothram varchar (50),@Rassi varchar(50),@HavinChildren varchar(10),@PhysicalStatus varchar (100))
as
begin
update Profile_Master
set FormFiledBy=@FormFiledBy,MaritalStatus=@MaritalStatus,Height=@Height,
Religion=@Religion,Caste=@Caste,MotherTongue=@MotherTongue,
Education=@Education,Occupation=@Occupation,CountryofResidence=@CountryofResidence,EducationDetails=@EducationDetails,
AnnualIncome=@AnnualIncome,CountryOfBirth=@CountryOfBirth,BirthPlace=@BirthPlace,TimeOfBirth=@TimeOfBirth,
StarSign=@StarSign,Gothram=@Gothram,Rassi=@Rassi,HavinChildren=@HavinChildren,PhysicalStatus=@PhysicalStatus
where UserId=@id
end
protected void Button1_Click(object sender, EventArgs e)
{
// Get User ID from DAL
int chk = 0;
if (Session["EmailID"] != null)
{
emailID = Session["EmailID"].ToString();
}
ProfileMasterBLL prfbll =new ProfileMasterBLL();
prfbll.EmailID = emailID;
string userid = ProfileMasterDAL.GetUserIdByEmailID(emailID);
// Capture remaining parameters
if (userid != null)
{
prfbll.FormFiledBy = RadioButtonList1.SelectedItem.Text;
prfbll.MaritalStatus = RadioButtonList2.SelectedItem.Text;
prfbll.Height = DropDownList1.SelectedItem.Text;
prfbll.PhysicalStatus = RadioButtonList4.SelectedItem.Text;
prfbll.Religion = DropDownList2.SelectedItem.Text;
prfbll.Caste = DropDownList3.SelectedItem.Text;
prfbll.MotherTongue = DropDownList4.SelectedItem.Text;
prfbll.Education = DropDownList5.SelectedItem.Text;
prfbll.Occupation = DropDownList6.SelectedItem.Text;
prfbll.CountryofResidence = DropDownList8.SelectedItem.Text;
prfbll.EducationDetails = TextBox3.Text;
prfbll.AnnualIncome = DropDownList7.SelectedItem.Text;
prfbll.CountryOfBirth = DropDownList9.SelectedItem.Text;
prfbll.BirthPlace = TextBox6.Text;
prfbll.TimeOfBirth = TextBox7.Text;
prfbll.StarSign = DropDownList10.SelectedItem.Text;
prfbll.Gothram = TextBox8.Text;
prfbll.Rassi = DropDownList12.Text;
if (RadioButtonList2.SelectedItem.Text != "Single")
{
prfbll.HavinChildren = RadioButtonList7.SelectedItem.Text;
}
else
{
RadioButtonList7.SelectedItem.Text = null;
}
}
try
{
chk = ProfileMasterDAL.update(prfbll);
if (chk >= 0)
{
Response.Write("<script language='javascript'>alert('details updated');</script>");
}
}
catch (Exception ex)
{
throw ex;
}
}
}
public static int update(ProfileMasterBLL profileMasterBLL)
{
SqlParameter uid;
SqlConnection conn = Generic.DBConnection.OpenConnection();
try
{
SqlCommand cmdd = new SqlCommand("sp_update", conn);
cmdd.CommandType = CommandType.StoredProcedure;
cmdd.Parameters.AddWithValue("@FormFiledBy", profileMasterBLL.FormFiledBy);
cmdd.Parameters.AddWithValue("@MaritalStatus", profileMasterBLL.MaritalStatus);
cmdd.Parameters.AddWithValue("@Height", profileMasterBLL.Height);
cmdd.Parameters.AddWithValue("@Religion", profileMasterBLL.Religion);
cmdd.Parameters.AddWithValue("@Caste", profileMasterBLL.Caste);
cmdd.Parameters.AddWithValue("@Education", profileMasterBLL.Education);
cmdd.Parameters.AddWithValue("@Occupation", profileMasterBLL.Occupation);
cmdd.Parameters.AddWithValue("@CountryofResidence", profileMasterBLL.CountryofResidence);
cmdd.Parameters.AddWithValue("@EducationDetails", profileMasterBLL.EducationDetails);
cmdd.Parameters.AddWithValue("@CountryOfBirth", profileMasterBLL.CountryOfBirth);
cmdd.Parameters.AddWithValue("@BirthPlace", profileMasterBLL.BirthPlace);
cmdd.Parameters.AddWithValue("@TimeOfBirth", profileMasterBLL.TimeOfBirth);
cmdd.Parameters.AddWithValue("@StarSign", profileMasterBLL.StarSign);
cmdd.Parameters.AddWithValue("@Gothram", profileMasterBLL.Gothram);
cmdd.Parameters.AddWithValue("@Rassi", profileMasterBLL.Rassi);
cmdd.Parameters.AddWithValue("@HavinChildren", profileMasterBLL.HavinChildren);
cmdd.Parameters.AddWithValue("@PhysicalStatus", profileMasterBLL.PhysicalStatus);
cmdd.Parameters.AddWithValue("@MotherTongue", profileMasterBLL.MotherTongue);
cmdd.Parameters.AddWithValue("@AnnualIncome", profileMasterBLL.AnnualIncome);
uid = cmdd.Parameters.Add("@id", System.Data.SqlDbType.Int);
uid.Direction = System.Data.ParameterDirection.Output;
return cmdd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
}
しかし、問題はDBで値が更新されていないことです。誰かが何が悪いのか教えてもらえますか?
public static int Insert(ProfileMasterBLL profileMasterBLL)
{
// bool flag = false;
SqlParameter pid;
SqlConnection con = Generic.DBConnection.OpenConnection();
try
{
SqlCommand cmd1 = new SqlCommand("Insertreg", con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@FirstName", profileMasterBLL.FirstName);
cmd1.Parameters.AddWithValue("@LastName", profileMasterBLL.LastName);
cmd1.Parameters.AddWithValue("@Dob", profileMasterBLL.Dob);
cmd1.Parameters.AddWithValue("@Gender", profileMasterBLL.Gender);
cmd1.Parameters.AddWithValue("@MobileNo", profileMasterBLL.MobileNo);
cmd1.Parameters.AddWithValue("@Country", profileMasterBLL.Country);
cmd1.Parameters.AddWithValue("@State", profileMasterBLL.State);
cmd1.Parameters.AddWithValue("@EmailId", profileMasterBLL.EmailID);
cmd1.Parameters.AddWithValue("@Password", profileMasterBLL.Password);
pid = cmd1.Parameters.Add("@id", System.Data.SqlDbType.Int);
pid.Direction = System.Data.ParameterDirection.Output;
return cmd1.ExecuteNonQuery();