SQLServerで完全に実行されるストアドプロシージャがあります。ただし、データアクセス層からasp.netに返される行にアクセスできません。
私のDataAccessLayer
コードは次のとおりです。
public List<AdvancePaymentRep> getPaymentAdvanceData(int? InternalCompany = 0, string Currency = "", DateTime? InvoiceDateFrom = null, DateTime? InvoiceDateTo = null, DateTime? AdvDateDueFrom = null, DateTime? AdvDateDueTo = null)
{
CreateConnectionString();
List<AdvancePaymentRep> paymentAdvanceCollection = new List<AdvancePaymentRep>();
SqlDataReader rdrval = null;
SqlCommand command1 = sqlConnection.CreateCommand();
command1.CommandType = System.Data.CommandType.StoredProcedure;
command1.CommandText = "[dbo].[NST_GetDataForAdvancePaymentReport]";
if (InternalCompany != 0)
{
SqlParameter parametersInternalCompany = new SqlParameter();
parametersInternalCompany.ParameterName = "@AlhInternalCie";
parametersInternalCompany.SqlDbType = System.Data.SqlDbType.Int;
parametersInternalCompany.Direction = ParameterDirection.Input;
parametersInternalCompany.Value = InternalCompany;
command1.Parameters.Add(parametersInternalCompany);
}
SqlParameter parametersCurrency = new SqlParameter();
parametersCurrency.ParameterName = "@AlhCurrency";
parametersCurrency.SqlDbType = System.Data.SqlDbType.NVarChar;
parametersCurrency.Direction = ParameterDirection.Input;
parametersCurrency.Value = Currency;
command1.Parameters.Add(parametersCurrency);
if (InvoiceDateFrom != Convert.ToDateTime("01/01/0001 00:00:00"))
{
SqlParameter parametersInvoiceDateFrom = new SqlParameter();
parametersInvoiceDateFrom.ParameterName = "@AldDtCreatedFrom";
parametersInvoiceDateFrom.SqlDbType = System.Data.SqlDbType.Date;
parametersInvoiceDateFrom.Direction = ParameterDirection.Input;
parametersInvoiceDateFrom.Value = InvoiceDateFrom;
command1.Parameters.Add(parametersInvoiceDateFrom);
}
if (InvoiceDateTo != Convert.ToDateTime("01/01/0001 00:00:00"))
{
SqlParameter parametersInvoiceDateTo = new SqlParameter();
parametersInvoiceDateTo.ParameterName = "@AldDtCreatedTo";
parametersInvoiceDateTo.SqlDbType = System.Data.SqlDbType.Date;
parametersInvoiceDateTo.Direction = ParameterDirection.Input;
parametersInvoiceDateTo.Value = InvoiceDateTo;
command1.Parameters.Add(parametersInvoiceDateTo);
}
if (AdvDateDueFrom != Convert.ToDateTime("01/01/0001 00:00:00"))
{
SqlParameter parametersInvoiceDateDueFrom = new SqlParameter();
parametersInvoiceDateDueFrom.ParameterName = "@InvhDtDueFrom";
parametersInvoiceDateDueFrom.SqlDbType = System.Data.SqlDbType.Date;
parametersInvoiceDateDueFrom.Direction = ParameterDirection.Input;
parametersInvoiceDateDueFrom.Value = AdvDateDueFrom;
command1.Parameters.Add(parametersInvoiceDateDueFrom);
}
if (AdvDateDueTo != Convert.ToDateTime("01/01/0001 00:00:00"))
{
SqlParameter parametersInvoiceDateDueTo = new SqlParameter();
parametersInvoiceDateDueTo.ParameterName = "@InvhDtDueTo";
parametersInvoiceDateDueTo.SqlDbType = System.Data.SqlDbType.Date;
parametersInvoiceDateDueTo.Direction = ParameterDirection.Input;
parametersInvoiceDateDueTo.Value = AdvDateDueTo;
command1.Parameters.Add(parametersInvoiceDateDueTo);
}
try
{
if (sqlConnection == null)
{
sqlConnection.Open();
}
rdrval = command1.ExecuteReader(); // Getting HasRows = false out here
編集:私がどのように供給したかについていくつかの問題があった問題を解決しました