Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
ALTER PROCEDURE dbo.usp_profile
	@user_id int
AS
	Begin
	SELECT     registration.user_id, registration.firstname, registration.lastname, registration.username, registration.state_id, registration.city_id, registration.pincode, 
                      registration.mobile_no, registration.phone_no, registration.e_mail, registration.address, registration.reg_date, state.state_name, city.city_name
FROM         registration INNER JOIN
                      state ON registration.state_id = state.state_id INNER JOIN
                      city ON registration.city_id = city.city_id AND state.state_id = city.state_id
					 
WHERE       registration.user_id = @user_id
	End



this is my stored procedure
and code.

C#
if (!IsPostBack)
       {
           SqlCommand cmd = new SqlCommand();
           cmd.CommandText = "usp_profile";
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Connection = con;
           cmd.Parameters.AddWithValue("@user_id",1);
           //Convert.ToInt16(Session["user_id"]));
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           da.Fill(dt);
           ViewState["dt"] = dt;
           dvprofile.DataSource = dt;
           dvprofile.DataBind();
       }
        else
       {
          dt = (DataTable)ViewState["dt"];
       }


here the detailsview is not getting filled i don't know why..
Posted
Updated 29-Mar-13 4:13am
v2
Comments
Member 9581488 29-Mar-13 9:17am    
exec usp_profile @userid=1
run this command in your sql management studio and see if its returning any result set.
Member 9671810 29-Mar-13 9:24am    
how?
i mean i am beginner so i dint get you.. :P
Member 9581488 29-Mar-13 9:30am    
in your sql's query analyzer.
Member 9671810 29-Mar-13 9:33am    
i tried but when i give id 10 its working but not with other id..
Member 9581488 29-Mar-13 9:36am    
change cmd.Parameters.AddWithValue("@user_id",1); to
cmd.Parameters.AddWithValue("@user_id",10);
and see if it binds the data with detailsview

1 solution

ALTER PROCEDURE dbo.usp_profile
	@user_id int
AS
	Begin
	SELECT     registration.user_id, registration.firstname, registration.lastname, registration.username, registration.state_id, registration.city_id, registration.pincode, 
                      registration.mobile_no, registration.phone_no, registration.e_mail, registration.address, registration.reg_date, state.state_name, city.city_name
FROM         registration INNER JOIN
                      state ON registration.state_id = state.state_id INNER JOIN
                      city ON registration.city_id = city.city_id
					 
WHERE       registration.user_id = @user_id
	End
 
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