try
{
string MemID = string.Empty;
using (MySqlConnection ObjCon = new MySqlConnection(new CommonClass().GetConnectionString()))
{
ObjCon.Open();
using (MySqlCommand ObjCmd = new MySqlCommand("SP_Beneficiary", ObjCon))
{
ObjCmd.CommandType = CommandType.StoredProcedure;
ObjCmd.Parameters.Add("SP_Id", MySqlDbType.Int64).Value = 0;//Pass Zero Here For Insert;
ObjCmd.Parameters.Add("SP_AccountNo", MySqlDbType.VarChar,15).Value = txtBeneAcc.Text.Trim();
ObjCmd.Parameters.Add("SP_Name", MySqlDbType.VarChar, 50).Value = txtBeneName.Text.Trim();
ObjCmd.Parameters.Add("SP_PhoneNumber", MySqlDbType.VarChar, 15).Value = txtBenePh.Text.Trim();
ObjCmd.Parameters.Add("SP_BankName", MySqlDbType.VarChar, 30).Value = ddlBeneBank.SelectedItem.Value;
ObjCmd.Parameters.Add("SP_BranchName", MySqlDbType.VarChar, 30).Value = txtBeneBranch.Text.Trim();
ObjCmd.Parameters.Add("SP_Cre_By", MySqlDbType.VarChar, 20).Value = "Raja";
ObjCmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
Response.Redirect(ex.Message);
}
DROP PROCEDURE IF EXISTS SP_Beneficiary;
CREATE PROCEDURE SP_Beneficiary(
IN SP_Id INT,
IN SP_AccountNo varchar(15) ,
IN SP_Name varchar(50),
IN SP_PhoneNumber varchar(15),
IN SP_BankName varchar(30),
IN SP_BranchName varchar(30),
IN SP_Cre_By varchar(20)
)
Begin
if SP_Id=0 then
INSERT INTO Beneficiary (AccountNo,Name,PhoneNumber,BankName,BranchName,Cre_Dt,Cre_By) VALUES (SP_AccountNo,SP_Name,SP_PhoneNumber,SP_BankName,SP_BranchName,CURDATE(),SP_Cre_By);
else
update Beneficiary set AccountNo=SP_AccountNo,Name=SP_Name,PhoneNumber=SP_PhoneNumber,BankName=SP_BankName,BranchName=SP_BranchName,Mod_Dt=CURDATE(),Cre_By=SP_Cre_By where id=SP_Id;
End if;
End;
No comments:
Post a Comment