我用ADOConnection1中的ODBC连接一个自由表DBF,查询字段内容是数字或字母时就可以查找到相应的数据,但字段内容是汉字时就无法查找了,比如name字段中的内容有"张学友","李三"这些数据,但无论是模糊(like)查找还是精确(=)查找都不行,都是一条记录都找不到,请各位大哥指点一下,我是不是还有什么没有设置好的。
我在ADOConnection1的ONCreate事件中写了以下连接表的代码
try
if vod_data.ADOConnection1.Connected=true then
vod_data.ADOConnection1.Connected:=false;
vod_data.ADOConnection1.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=Visual FoxPro Tables;UID=;SourceDB=' +gc_query.vod_dir+'\DATA;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;";Initial Catalog=c:\song\data';
vod_data.ADOConnection1.Connected:=true;
except
showmessage('连接数据库出错!');
//exit;
end;
在ADOQUERY1中用以下句子查询
vod_data.adoquery1.Close;
vod_data.adoquery1.SQL.Clear;
if dxedit1.Text<>'' then
begin
vod_data.adoquery1.sql.add('select * from song.dbf where singer1 like :gx');
vod_data.ADOQuery1.Parameters.ParamByName('gx').Value:='%'+dxedit1.Text+'%';
end
else
begin
vod_data.adoquery1.sql.add('select * from song.dbf');
end; try
vod_data.adoquery1.Open;
except
showmessage('查询数据出错!');
end;
我在ADOConnection1的ONCreate事件中写了以下连接表的代码
try
if vod_data.ADOConnection1.Connected=true then
vod_data.ADOConnection1.Connected:=false;
vod_data.ADOConnection1.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Extended Properties="DSN=Visual FoxPro Tables;UID=;SourceDB=' +gc_query.vod_dir+'\DATA;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=Yes;";Initial Catalog=c:\song\data';
vod_data.ADOConnection1.Connected:=true;
except
showmessage('连接数据库出错!');
//exit;
end;
在ADOQUERY1中用以下句子查询
vod_data.adoquery1.Close;
vod_data.adoquery1.SQL.Clear;
if dxedit1.Text<>'' then
begin
vod_data.adoquery1.sql.add('select * from song.dbf where singer1 like :gx');
vod_data.ADOQuery1.Parameters.ParamByName('gx').Value:='%'+dxedit1.Text+'%';
end
else
begin
vod_data.adoquery1.sql.add('select * from song.dbf');
end; try
vod_data.adoquery1.Open;
except
showmessage('查询数据出错!');
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货