数据库字符串匹配问题!!数据库字符串匹配问题!!数据库字符串匹配问题!!

shenwenliang 2001-05-28 09:29:00
有一张数据表,带有M类型字段,当作注释!
我用DBMEMO显示了注释的内容,现在想实现检索功能
即输入一个想查找的字符串,程序就查找全部记录的注释
然后DBMEMO中就显示带有此字符串的那条注释,并且使注释里字符串被选中!
...全文
108 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shenwenliang 2001-05-30
  • 打赏
  • 举报
回复
我用模糊查询解决了问题!!
WuHeHai 2001-05-30
  • 打赏
  • 举报
回复
那就用
strList.ADD(Dataset.FieldByName( 'Memo' ).AsString);
wangxd1976 2001-05-29
  • 打赏
  • 举报
回复
俺试过了,可以(paradox)
wangxd1976 2001-05-29
  • 打赏
  • 举报
回复
SQL Server的Text类型可以用Like匹配字符串模糊查询,如下:
select * from notedx
where neirong like '%AAA%'
不知道Memo类型支持不支持,试试吧
shenwenliang 2001-05-28
  • 打赏
  • 举报
回复
谢谢你!
不过还有有一个问题
就是你的:strList ;= Dataset.FieldByName( 'Memo' ).AsString; 这条语句
strList是TStringList类型的,后面的是不能赋值给它的!
WuHeHai 2001-05-28
  • 打赏
  • 举报
回复
var
strList: TStringList;
iStart: Integer;
begin
DataSet.Disablecontrols;
DataSet.First;
strList := TStringList.Create;
iStart := 0;
//逐条记录遍历
While not DataSet.Eof do
begin
//取出Memo字段的内容,并查找字符串
strList ;= Dataset.FieldByName( 'Memo' ).AsString;
iStart := Pos(strFind, strList.Text);
//若有含有想查找的字符串,则推出
if iStart > 0 then Break;
next;
end;
DataSet.EnableControls;
if iStart > 0 then
begin
DBMemo.SelStart := iStart;
DBMemo.SelLength ;= Length(strFind);
end;

end;

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧