umair mohsin

umair mohsin

  • 1.3k
  • 387
  • 64.5k

Resume Page question

May 5 2017 1:38 PM
I wonna make a resume application in which only registered users are allowed to make resumes,
And some of the fields should filled by using their sign up details and others will fill by the user at runtime
I wonna do this thing using stored procedures i am trying this code on stored procedure
 
USE [APJobPortalDB]
CREAT PROCEDURE [dbo].[SelectUserDetailsForResume]
@UserId varchar(50)
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here;
SELECT * from Sign_Up where UserId=@UserId;
END
And in code behind i use this code
 
if (Page.Session["user"]!=null)
{
string constr = ConfigurationManager.ConnectionStrings["JPConstr"].ConnectionString.ToString();
SqlCommand cmd = new SqlCommand();
using (SqlConnection conn = new SqlConnection(constr))
{
conn.Open();
cmd.Connection = conn;
cmd = new SqlCommand("SelectUserDetailsForResume”, conn); //
cmd.Paramters.AddWithValue(“@UserId”,Page.Session[“user”]);
SqlDataReader sdr = cmd.ExecuteReader();
cmd.CommandType = CommandType.StoredProcedure;
while (sdr.Read())
{
txtname.Text = sdr["FullName"].ToString();
txtid.Text = sdr["UserId"].ToString();
ddlgender.SelectedValue = sdr["Gender"].ToString();
txtcity.Text = sdr["City"].ToString();
txtemail.Text = sdr["Email"].ToString();
txtcontact.Text = sdr["Contact"].ToString();
}
conn.Close();
}
I am sure the code is quite clear i may not need to simplify this.
By using this code textboxes are still empty which should be filled with appropriate user details.user id is supplied when user is logged in.on the contrary if i am using a single line query the issue is resolved that query is:
"select * from Sign_Up where UserId='" + Page.Session["user"].ToString() + "'"
The textboxes on the resume are now fillled with user details. I don’t know what is wrong as i am passing User id from session in my stored procedure but still not happening.can anyone help me to resolve this issue.i wonna make use of my stored procedure not this single line query.
 
an explanation would be helpful and appriciable.thanks

Answers (1)