hmahdavi921
چهارشنبه 17 تیر 1394, 20:25 عصر
با سلام
من میخوام یک رشته رو که در پراسیجر به صورت خروجی تعریف کردم با ado بخونم
protected string PDGetMobile(string iduser)
{
try
{
SqlCommand sqlcom = new SqlCommand();
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.CommandText = "sp_Get_mobile";
SqlParameter outParameter = new SqlParameter("@mobile", "12345678901")
{
Direction = ParameterDirection.Output
};
sqlcom.Parameters.AddWithValue("@id_user", iduser);
SqlParameter outPutParameter = new SqlParameter();
outPutParameter.ParameterName = "@id_user";
outPutParameter.SqlDbType = System.Data.SqlDbType.NChar;
outPutParameter.Direction = System.Data.ParameterDirection.Output;
sqlcom.Parameters.Add(outPutParameter);
sqlcom.Connection = Sqlcon.OpenCon();
sqlcom.ExecuteReader();
return outParameter.Value.ToString();
}
catch
{
return "not found";
}
finally { Sqlcon.CloseCon(); }
}
ALTER PROCEDURE [dbo].[sp_Get_mobile]
/************************************************** *********
* Code generated by SoftTree SQL Assistant © v6.3.153
*
* Procedure description: This procedure is used for
* retrieving records from table
* dbo
* Date: 07/07/2015
* Author: hossein
*
* Changes
* Date Modified By Comments
************************************************** **********
* 07/07/2015 hossein Initial version
************************************************** **********/
(
@id_user NCHAR (100) , @mobile NCHAR (11) OUTPUT
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @rowcount INT, @error INT
-- search and return records
SELECT @mobile = mobile
FROM [dbo].[T_profile]
WHERE id_user = @id_user
-- capture operation completion code and number of records affected
SELECT @rowcount = @@ROWCOUNT,
@error = @@ERROR
IF @error != 0
BEGIN
-- report error and exit with non-zero exit code
RAISERROR('Unable to retrieve records. See previous message for details.', 16, 1)
RETURN @error
END
IF @rowcount = 0
BEGIN
-- report error and exit with non-zero exit code
RAISERROR('Critical error. No records found for the specified criteria.', 16, 1)
RETURN 1
END
IF @rowcount > 1
BEGIN
-- report error and exit with non-zero exit code
RAISERROR('Warning. More than 1 record found for the specified criteria, while just 1 is expected.', 10, 1)
RETURN 1
END
-- commit changes and return 0 code indicating successful completion
RETURN 0
END
دوستان لطفا اگر مشکلی هست راهنمایی بفرمائید. ممنون
من میخوام یک رشته رو که در پراسیجر به صورت خروجی تعریف کردم با ado بخونم
protected string PDGetMobile(string iduser)
{
try
{
SqlCommand sqlcom = new SqlCommand();
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.CommandText = "sp_Get_mobile";
SqlParameter outParameter = new SqlParameter("@mobile", "12345678901")
{
Direction = ParameterDirection.Output
};
sqlcom.Parameters.AddWithValue("@id_user", iduser);
SqlParameter outPutParameter = new SqlParameter();
outPutParameter.ParameterName = "@id_user";
outPutParameter.SqlDbType = System.Data.SqlDbType.NChar;
outPutParameter.Direction = System.Data.ParameterDirection.Output;
sqlcom.Parameters.Add(outPutParameter);
sqlcom.Connection = Sqlcon.OpenCon();
sqlcom.ExecuteReader();
return outParameter.Value.ToString();
}
catch
{
return "not found";
}
finally { Sqlcon.CloseCon(); }
}
ALTER PROCEDURE [dbo].[sp_Get_mobile]
/************************************************** *********
* Code generated by SoftTree SQL Assistant © v6.3.153
*
* Procedure description: This procedure is used for
* retrieving records from table
* dbo
* Date: 07/07/2015
* Author: hossein
*
* Changes
* Date Modified By Comments
************************************************** **********
* 07/07/2015 hossein Initial version
************************************************** **********/
(
@id_user NCHAR (100) , @mobile NCHAR (11) OUTPUT
)
AS
BEGIN
SET NOCOUNT ON
DECLARE @rowcount INT, @error INT
-- search and return records
SELECT @mobile = mobile
FROM [dbo].[T_profile]
WHERE id_user = @id_user
-- capture operation completion code and number of records affected
SELECT @rowcount = @@ROWCOUNT,
@error = @@ERROR
IF @error != 0
BEGIN
-- report error and exit with non-zero exit code
RAISERROR('Unable to retrieve records. See previous message for details.', 16, 1)
RETURN @error
END
IF @rowcount = 0
BEGIN
-- report error and exit with non-zero exit code
RAISERROR('Critical error. No records found for the specified criteria.', 16, 1)
RETURN 1
END
IF @rowcount > 1
BEGIN
-- report error and exit with non-zero exit code
RAISERROR('Warning. More than 1 record found for the specified criteria, while just 1 is expected.', 10, 1)
RETURN 1
END
-- commit changes and return 0 code indicating successful completion
RETURN 0
END
دوستان لطفا اگر مشکلی هست راهنمایی بفرمائید. ممنون