First at all, i know questions like these are duplicate BUT, please pay attention to this expect one. Here is my C# code behind which raise the error as :
Procedure or function 'aaa' expects parameter '@bbb', which was not supplied.
if (Dt.Rows.Count > 0)
{
Cmd = new SqlCommand();
Cmd.CommandText = ("[dbo].[aaa]");
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.Add("@bbb", SqlDbType.Int).Value = 1;
Cmd.Parameters.Add("@LettType", SqlDbType.VarChar, 3).Value = LetterType;
Cmd.Parameters.Add("@IsTajamo", SqlDbType.Char, 1).Value = 1;
Da = new SqlDataAdapter(Cmd.CommandText, Con);
Dt.Clear();
/*Line72:*/
Da.Fill(Dt);
}
Technically, I can't found where is the error. I passed all parameters. And when i execute my stored procedure separately in MS-SQL It work right with these values.
Can you experts please help me on this issue? Attention : here is Stored Proc :
ALTER PROCEDURE [dbo].[aaa] (@bbb Int , @LettType CHAR(3) , @IsTajamo CHAR(1))
AS
BEGIN
select 1
END
Attention : (may be this can help, here is my stack-trace) :
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action
1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) at WebService.Services.GetLettersList(String UserName, String PassPhrase, String CodeName, String LetterType) in D:\Amiri\WebService\WebService\Services.asmx.cs:line 79
In your line:
you are only passing the name of the procedure and ignoring the parameters. Pass only
Cmd
(and add that connection to the command) to use your defined params.