在form上放下列控件:
TEdit
TADOConnection
TADOQuery
TDataSource
TDBGrid
TButtonTADOConnection、TADOQuery、TDataSource、TDBGrid已正确设置好,TButton的click代码如下:procedure TForm1.Button2Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select id as 编号,userid as 帐号,userpass as 密码,username as 姓名 from user where userid='+'edit1.text');
//prepare;
open;
//sql.SaveToFile('ytf.xls') //该怎么写该句???
end;
end;当执行到open时发生错误,提示odbc参数不足,请问怎么修改上述事件过程?另外,为什么不能用类似TQuery的命令(parambyname)给sql语句的参数赋值
sql.Add('select id as 编号,userid as 帐号,userpass as 密码,username as 姓名 from user where userid=:uid');
parambyname('uid').asstring:=edit1.text;
prepare;
open;
TEdit
TADOConnection
TADOQuery
TDataSource
TDBGrid
TButtonTADOConnection、TADOQuery、TDataSource、TDBGrid已正确设置好,TButton的click代码如下:procedure TForm1.Button2Click(Sender: TObject);
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select id as 编号,userid as 帐号,userpass as 密码,username as 姓名 from user where userid='+'edit1.text');
//prepare;
open;
//sql.SaveToFile('ytf.xls') //该怎么写该句???
end;
end;当执行到open时发生错误,提示odbc参数不足,请问怎么修改上述事件过程?另外,为什么不能用类似TQuery的命令(parambyname)给sql语句的参数赋值
sql.Add('select id as 编号,userid as 帐号,userpass as 密码,username as 姓名 from user where userid=:uid');
parambyname('uid').asstring:=edit1.text;
prepare;
open;
begin
if active =true then
active:=false;
sql.Clear;
sql.Add('select id as 编号,d as 帐号 from 客户 where id='+edit1.text);//数字型
//字符型 sql.Add('select id as 编号,d as 帐号 from 客户 where id='+''''+edit1.text+'''');
showmessage(sql.Text);
ExecSQL ;
active:=true;
sql.SaveToFile('c:\ytf.xls');
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select id as 编号,userid as 帐号,userpass as 密码,username as 姓名 from user where userid='+'edit1.text');
//prepare;
excuse;
open;
end;格式是这样的,不知道单词写对了没有。
在DELPHI5时有过类似问题,但6,7就没有了.