sql2000的问题!help me(100分)

S

studing

Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是adotable和sql相连,编的查询语句,总是出错,提示在保存的程序文件夹中没有找到数据库table
程序如下:
var
asql:string;
begin
if combobox1.text<>'' then asql:='combobox1.text="'+edit1.text+'"'
else show('wrong');
with form1 do
begin
query1.sql.text:='select * from table where '+asql;
query1.close;
datasource1.dataset:=query1;
query1.open;
end;
end.


 
那应该是你的conectionstring没设置好 了
 
query1.sql.text:='select * from table where '+asql;
这里的是不是你的真是代码,如果是,Table是关键字,最好不作为表名,非作为表明的话,如下:
query1.sql.text:='select * from
where '+asql;
 
1.连接是否正常,用ADOTABLE试试.
2.用一个adoconnecton来连接数据库,然后其它的adotable和adoquery连接
adoconneciton多好.
3,检查一下你的SQL语句是否在SQL中执行正常.
 
检查一下你的asql 是不是有问题?????
 
次问题是5分,望斑竹给该以下,谢了!
 
看看:Query 的 ConectionString 是否连接好。
其实你可以用:AdoConnecton来连接数据库,然后设AdoQuery连接到
adoconneciton
 
>>if combobox1.text<>'' then asql:='combobox1.text="'+edit1.text+'"'
>>...
>>query1.sql.text:='select * from table where '+asql;
你得到的结果是:
query1.sql.text = 'select * from table where combobox1.text = '....

应该是 if trim(combobox1.text) <> '' then asql := trim(combobox1.text) + '= ''' + trim(edit1.text) + '''';
另:adoquery中是不能用双引号的!
 
你的ConnString里面没有制定操作的数据库
 
把你的adotable换成adoquery
 
不是看,就知道是asql的连接字符串语句有误!
var
asql:string;
begin

if combobox1.text<>'' then asql:='combobox1.text="'+edit1.text+'"'
else show('wrong');
with form1 do
begin
query1.sql.text:='select * from table where 字段名='+chr(39)+combobox1.text+chr(39));
query1.sql.text:='select * from table where 字段名='+chr(39)+edit1.text+chr(39));
query1.close;
datasource1.dataset:=query1;
query1.open;
end;
end.

 
分分有点晚了!对不助了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
650
import
I
顶部