Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a query to get all values from a table using store procedure in asp.net

SQL
SELECT * FROM TblAppUser WHERE UserId = @UserID


I have write this StorProcedure.
SQL
CREATE PROC uspGetUserProfile
@UserID int,@UserName VARCHAR(20) OUT,@Email VARCHAR(50) OUT,@NIC bigint OUT,@CreatedDate datetime OUT,
@FirstName Varchar(20) OUT,@LastName Varchar(20) OUT,@FatherName Varchar(30) OUT,@DateofBirth date OUT,
@OfficeAddress Varchar(max) OUT,@City Varchar(15) OUT,@Proivnce Varchar(15) OUT,@WorkPhone Varchar(25) OUT,
@Avatar image OUT
AS
BEGIN
SELECT * FROM TblAppUser WHERE UserId = @UserID

END


But in this way i have to get lot of output parameters. is there another way to get all these using single or less query.
Posted
Comments
[no name] 18-Apr-14 19:52pm    
Yes.... why don't you just use a single query?
Muhammad Taqi Hassan Bukhari 18-Apr-14 19:55pm    
My professor told me to only use store procedure not queries. So, i have to get this using store procedure

1 solution

You Can try this..Very Sort

CREATE PROC uspGetUserProfile
@UserID int
AS
BEGIN
SELECT * FROM TblAppUser WHERE UserId = @UserID
END
 
Share this answer
 
Comments
Muhammad Taqi Hassan Bukhari 19-Apr-14 1:56am    
This is OK, now how would i have to catched these parameters in asp.net, is the normal way that we get out parameters???? like this
db1.sqlcmd.Parameters.Add("@RLoginDate", SqlDbType.VarChar, 20);
db1.sqlcmd.Parameters["@RLoginDate"].Direction = ParameterDirection.Output;
LabelLastLogin.Text = (string)db1.sqlcmd.Parameters["@RLoginDate"].Value;

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