パラメータが追加されているコードをステップ実行すると、SQLコマンドが実行されたときに、このエラーがスローされます
public static DataTable GetPostings2(string AssetNumberV, string PeriodFromV, string PeriodToV)
{
DataTable dtGetPostings2;
try
{
dtGetPostings2 = new DataTable("GetPostings");
SqlParameter AssetNumber = new SqlParameter("@AssetNumber", SqlDbType.VarChar, 6);
AssetNumber.Value = AssetNumberV;
SqlParameter PeriodFrom = new SqlParameter("@PeriodFrom", SqlDbType.VarChar, 6);
PeriodFrom.Value = PeriodFromV;
SqlParameter PeriodTo = new SqlParameter("@PeriodTo", SqlDbType.VarChar, 6);
PeriodTo.Value = PeriodToV;
SqlCommand scGetPostings2 = new SqlCommand("SELECT * FROM [POSTING] WHERE [ASSET_NO] = @AssetNumber And PERIOD >= @PeriodFrom AND PERIOD <= @PeriodTo ORDER by PERIOD, JOUR_REF, JOUR_LINE", DataAccess.AssetConnection);
SqlDataAdapter sdaGetPostings2 = new SqlDataAdapter();
sdaGetPostings2.SelectCommand = scGetPostings2;
sdaGetPostings2.Fill(dtGetPostings2);
return dtGetPostings2;
}
catch (Exception ex)
{
MessageBox.Show("Error Retriving Posting Details: Processed with this error:" + ex.Message);
return null;
}
}