public int InsertCompanyDetailsInformation(int companyId, int bankId, int accountNo, string accountType)
{
int rowsAffected = -1;
int returnValue;
try
{
SqlConnection con = DBProvider.GetDbConnection();
using (con)
{
con.Open();
SqlCommand objCmd = new SqlCommand("dbo.sp_InsertCompanyDetailsInformation", con);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.AddWithValue("@companyId", companyId);
objCmd.Parameters.AddWithValue("@bankId", bankId);
objCmd.Parameters.AddWithValue("@accountNo", accountNo);
objCmd.Parameters.AddWithValue("@accountType", accountType);
rowsAffected = objCmd.ExecuteNonQuery();
SqlParameter sqlParam = objCmd.Parameters.Add("@insert_flag", SqlDbType.Int);
objCmd.Parameters["@insert_flag"].Direction = ParameterDirection.ReturnValue;
returnValue = int.Parse(objCmd.Parameters["@insert_flag"].Value.ToString());
con.Close();
}
}
catch (Exception ex)
{
throw ex;
}
return rowsAffected;
}
にSQLサーバに設定フラグとストアドプロシージャのアクセスもする方法ビジネスロジック
USE [SGTime_Development]
GO
/****** Object: StoredProcedure [dbo].[sp_InsertCompanyDetailsInformation] Script Date: 01/04/2011 14:31:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_InsertCompanyDetailsInformation]
(
@companyId int,
@bankId int,
@accountNo int,
@accountType varchar(50))
AS
BEGIN
SET NOCOUNT ON;
declare @insert_flag int;
if not exists(select AccountNo from [Company_Account_Details] where [email protected])
begin
INSERT INTO [Company_Account_Details]
(Company_Id,
BankID,
AccountNo,
AccountType)
values
(@companyId,
@bankId,
@accountNo,
@accountType)
set @insert_flag=1;
END
else
begin
set @insert_flag=-1;
end
return @insert_flag;
end
私たちは のreturnValue
を返すことができますどのように助けてください、私はInsertCompanyDetailsInformationでのreturnValueを返したいコードのエラーを取得しています
をいくつかworng – Rajesh