我要完成的功能就是用户能同时使用汉字和拼音对库进行查询,找到数据后,回车就下转到下一个combobox.
我的想法是这样的:
如果combobox1.text输入的是汉字就查询数据中汉字字段的内容,如果库中有这个数据,则执行combobox2.setfocus,如果combobox.text是字母就查询数据库中字母字段的内容,如何实现.我的部分语句如下
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key<=#128 THEN
begin
if Key=#13 then
begin
with adoqueryjbqk do
begin
close;
Sql.Clear;
Sql.Add('select sxmc from mingxi where sxlbid=003 and sxpy like '''+combobox1.text+'%''');
Open;
combobox1.items.clear;
First;
while not eof do
begin
combobox1.items.add(fieldbyname('sxmc').asstring);
Next;
end;
end;
end;
end
else if key>=#128 then
begin
if Key=#13 then
begin
下面不知如何写了
我的想法是这样的:
如果combobox1.text输入的是汉字就查询数据中汉字字段的内容,如果库中有这个数据,则执行combobox2.setfocus,如果combobox.text是字母就查询数据库中字母字段的内容,如何实现.我的部分语句如下
procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key<=#128 THEN
begin
if Key=#13 then
begin
with adoqueryjbqk do
begin
close;
Sql.Clear;
Sql.Add('select sxmc from mingxi where sxlbid=003 and sxpy like '''+combobox1.text+'%''');
Open;
combobox1.items.clear;
First;
while not eof do
begin
combobox1.items.add(fieldbyname('sxmc').asstring);
Next;
end;
end;
end;
end
else if key>=#128 then
begin
if Key=#13 then
begin
下面不知如何写了
st:=st+'where 汉字字段 like '''+Edit.text+'%'' or '字母字段 like '''+Edit.text+'%''';楼主不要把问题想得复杂化了。字母字段里面是不会有汉字的,虽然汉字字段时间有可能包含字母。但是几率是很低的
照我的方法做不会有问题