열이 주어진 매개 변수와 일치하는 테이블에서 선택하려고합니다. 매개 변수가 null 인 경우 테이블에서 모든 레코드를 선택합니다. 아래의 관련 코드는이 오류를 발생시키는 것입니다.함수의 지정된 인수 값이 유효하지 않습니다. [Argument # = 1, 함수 이름 (알려진 경우) = isnull]
private static string _dbJobCreate =
"CREATE TABLE Job (jID int primary key identity(1,1), jAddress nvarchar(64) not null);";
private static string _dbJobSelect =
"SELECT jID FROM Job WHERE jAddress = @jAddress OR @jAddress IS NULL";
public static DataTable GetJobs(string jAddress)
{
SqlCeParameter pjAddress = new SqlCeParameter();
pjAddress.ParameterName = "@jAddress";
if (!string.IsNullOrEmpty(jAddress))
{
pjAddress.Value = jAddress;
}
else
{
pjAddress.Value = DBNull.Value;
}
return ExecuteDataTable(_dbJobSelect, pjAddress);
}
예외 : The specified argument value for the function is not valid. [ Argument # = 1,Name of function(if known) = isnull ]
어떻게 효율적으로 SQLCE에서 오류없이이 작업을 수행 할 수 있습니까?
유용한 토론 : http://social.msdn.microsoft.com/Forums/sqlserver/en-US/83821937-3929-4901-a78e-b675cf8a70ca/how-to-send-a-null-value-as -a-parameter –