Hi!can anyone help pliz...
I am using c#.net 2010 and sql sever 2008.I am getting the following error:
<<Procedure or function transfertcash has too many arguments specified>>.
protected void BtnSend_Click(object sender, EventArgs e)
{
SqlConnection sqlconnection = new SqlConnection("Data source=NDEKEZIDANIEL\\SQLEXPRESS;Initial catalog=ECASH;integrated security=true");
SqlCommand sqlcommand = new SqlCommand("transfertcash", sqlconnection);
sqlcommand.Parameters.Add("@numb", SqlDbType.BigInt).Value = Int64.Parse(TextBoxBenTel.Text.Trim());
sqlcommand.Parameters.Add("@montant", SqlDbType.Int).Value = Int32.Parse(TextBoxMontant.Text.Trim());
sqlcommand.Parameters.Add("@numtel", SqlDbType.BigInt).Value = Session["num_tel"];
sqlcommand.Parameters.Add("@code", SqlDbType.NVarChar,50).Value = TextBoxPassword.Text.Trim();
sqlcommand.Parameters.Add("@msg_to_send", SqlDbType.NVarChar, 4000).Value = "";
sqlcommand.Parameters["@msg_to_send"].Direction = ParameterDirection.Output;
sqlcommand.Parameters.Add("@returnValue",SqlDbType.Int).Value=ParameterDirection.ReturnValue;
else
{
sqlconnection.Open();
sqlcommand.CommandType = CommandType.StoredProcedure;
sqlcommand.ExecuteNonQuery();
int exists = (int)sqlcommand.Parameters["@returnValue"].Value;
if (exists == 1)
{
Lblsms.Text = "<font color='green'>Ecash transfered successfully!</font>";
}
else
{
Lblsms.Text = "<font color='red'>Transfer failed,please contact the service center!";
}
sqlconnection.Close();
}
}
#endregion
}
and i have the following stored precedure:
ALTER PROC [dbo].[transfertcash]
(
@numb BIGINT,
@montant INT,
@numtel BIGINT,
@code NVARCHAR(50),
@msg_to_send as NVARCHAR(4000) OUTPUT
)
AS
BEGIN
DECLARE @AccountStatus varchar(50)
DECLARE @AvailableBalance INT
DECLARE @TransactionID BIGINT
DECLARE @nom VARCHAR(50)
DECLARE @prenom VARCHAR(50)
IF NOT(@montant >= 1000 AND @montant <= 100000)
BEGIN
SET @msg_to_send= 'Invalid Amount! The amount must be in range 1000-100000'
RETURN 0
END
--Ensure the number is valid and account is open
IF EXISTS(Select numtel from MyLogin where numtel = @numtel AND idsession = @code )
BEGIN
--Check if his account is opened
SET @AccountStatus = (select etat from McellAcc where numtel = @numtel)
IF(@AccountStatus = 'opened')
BEGIN
--Account is active make the transaction
--Check if he has sufficient amount
SET @AvailableBalance = (SELECT solde FROM McellAcc WHERE numtel = @numtel)
IF(@AvailableBalance >= @montant)
BEGIN
--Transfer the money
BEGIN TRANSACTION
--Debit the account
BEGIN TRY
UPDATE McellAcc SET solde = solde - @montant WHERE numtel=@numtel
INSERT INTO TransactionM( --retrait cpte tigo
numtel,
debitmonta,
creditmonta,
DateTrans,
taux,
etat
)
values(
@numtel,
@montant,
0,
getdate(),
(@montant * 5/100),
'Pending...'
)
--RETURN 1
SET @TransactionID = @@IDENTITY
SET @nom=(SELECT nom FROM MyLogin WHERE numtel=@numtel)
SET @prenom=(SELECT prenom FROM MyLogin WHERE numtel=@numtel)
SET @msg_to_send = 'You received '+''+'FRW'+cast(@montant AS VARCHAR(15))+' from '+@nom+' '+@prenom+'.The transaction ID: ' + CAST(@TransactionID AS VARCHAR(20))
INSERT INTO ozekimessageout(receiver,msg,[status]) VALUES (@numb,@msg_to_send,'send')
COMMIT TRANSACTION
RETURN 1
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
SET @msg_to_send = 'Transfer failed! Please try again.'
RETURN 0
RETURN
END CATCH
END
ELSE
BEGIN
-- Insufficient amount
SET @msg_to_send= 'Insufficient Amount!'
RETURN 0
END
END
ELSE
BEGIN
--Account is deactive, inform the user
SET @msg_to_send= 'Account Deactive! You account is deactive, please activate your account'
RETURN 0
END
END
ELSE
BEGIN
-- Tell use his number is incorret
SET @msg_to_send= 'Invalid Number!'
RETURN 0
END
END