1
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 以外的值时,则没有错误。

4

1 回答 1

2

尝试这个:

SELECT * FROM Person 
WHERE (? IS NULL AND Name IS NULL) OR Name = ?
于 2014-04-14T21:55:19.520 回答