我的SQL代码在服务器上运行。
SELECT
[LINE_NO], [CUST_ORDER_ID], [PART_ID],
[CUSTOMER_PART_ID], [MISC_REFERENCE], [PROMISE_DATE],
[PROMISE_DEL_DATE]
FROM
[CUST_ORDER_LINE]
WHERE
([CUST_ORDER_ID] = '33742-1'
AND [PROMISE_DATE] IS NULL
AND [PROMISE_DEL_DATE] IS NULL)
我的asp.net代码。
SelectCommand = "SELECT [LINE_NO], [CUST_ORDER_ID], [PART_ID], [CUSTOMER_PART_ID], [MISC_REFERENCE], [PROMISE_DATE], [PROMISE_DEL_DATE] FROM [CUST_ORDER_LINE] WHERE ([CUST_ORDER_ID] = ? AND [PROMISE_DATE] = ? AND [PROMISE_DEL_DATE] = ?)"
我正在使用3个查询字符串参数。承诺日期和承诺交付日期可以为空。但是当这些值为null时,它不返回任何记录。
如何对此进行编程以将SQL更改为'is null'
而不是= ''
。
答案 0 :(得分:0)
我认为这就是你想要的:
代码:
https: before //ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
SQL将是:
SelectCommand = "SELECT [LINE_NO], [CUST_ORDER_ID], [PART_ID], [CUSTOMER_PART_ID], [MISC_REFERENCE], [PROMISE_DATE], [PROMISE_DEL_DATE] FROM [CUST_ORDER_LINE] WHERE [CUST_ORDER_ID] = ? AND (? IS NULL OR [PROMISE_DATE] = ?) AND (? IS NULL OR [PROMISE_DEL_DATE] = ?)"