var dbParameter = command.CreateParameter();
dbParameter.Name = "myParam";
dbParameter.Value = DBNull.Value;
command.Parameters.Add(dbParameter);
sql是这样的:
select * from Person where Name is ?
Get an error:
An exception of type 'InterSystems.Data.CacheClient.CacheException'
occurred in InterSystems.Data.CacheClient.dll but was not handled in user code
Additional information: [SQLCODE: <-1>:<Invalid SQL statement>]
[Location: <Prepare>]
[%msg: < NULL expected, : found^select * from Person where Name is :%qpar>]
当查询更改为where Name = ?
并设置了 DBNull.Value 以外的值时,则没有错误。