首先我們需要知道在Access中null和空字串是不同的,因此如果處理不好該問題就會帶來不少麻煩,特別是在混合查詢中。
(推薦教學:access資料庫學習)
解決方法如下:
var SQLStr:string; begin // SQLStr := 'select * from ordertb where 1>0'; if Trim(Edit1.Text)<>'' then SQLStr := SQLStr +' and serialid like :a'; if Trim(Edit2.Text)<>'' then SQLStr := SQLStr +' and pname like :b'; with ADOQuery1 do begin Close; SQL.Clear; SQL.Add(SQLStr); if Trim(Edit1.Text)<>'' then Parameters.ParamByName('a').Value := '%'+Trim(Edit1.Text)+'%'; if Trim(Edit2.Text)<>''then Parameters.ParamByName('b').Value := '%'+Trim(Edit2.Text)+'%'; Open; end; end;
或:
begin with ADOQuery1 do begin Close; SQL.Clear; SQL.Add('select * from ordertb where 1>0'); if Trim(Edit1.Text)<>'' then SQL.Add(' and serialid like ''%'+Trim(Edit1.Text)+'%'''); if Trim(Edit2.Text)<>''then SQL.Add(' and pname like ''%'+Trim(Edit2.Text)+'%'''); Open; end; end;
總結:
將條件為空的欄位從查詢語句中篩選掉。
以上是access刪除空白欄位記錄的詳細內容。更多資訊請關注PHP中文網其他相關文章!
陳述
本文轉載於:csdn。如有侵權,請聯絡admin@php.cn刪除

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章
刺客信條陰影:貝殼謎語解決方案
4 週前ByDDD
Windows 11 KB5054979中的新功能以及如何解決更新問題
3 週前ByDDD
在哪裡可以找到原子中的起重機控制鑰匙卡
4 週前ByDDD
<🎜>:死鐵路 - 如何完成所有挑戰
1 個月前ByDDD
Atomfall指南:項目位置,任務指南和技巧
1 個月前ByDDD

熱工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

記事本++7.3.1
好用且免費的程式碼編輯器

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

WebStorm Mac版
好用的JavaScript開發工具