请看我的代码,为什么老是提示说没定义ParamByName
我在uses 里已经引用了adodb的;procedure Tcjcx_fr.mh_btClick(Sender: TObject);
var s:string;
begin
with stuxinxi_Dm do
begin
s:=quotedstr(trim(gjz_ed.text));
adoquery1.Close;
adoquery1.SQL.Clear;
case mhtj_rg.ItemIndex of
//0:按姓名搜索;1:按课程名搜索 0:adoquery1.SQL.Add('Select * From chengjibiao where stu_no in(select stu_no from xuejibiao where stu_name Like :str');
//分姓名的3种输入情况搜索成绩表
if LeftStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:=s+'%' //左匹配
else if RightStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s //右匹配
else
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s+'%'; //中间匹配 1:adoquery1.SQL.Add('Select * From chengjibiao where kecheng_no in(select kecheng_no from kechengbiao where kecheng_name Like :str');
//分课程名的3种输入情况搜索成绩表
if LeftStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:=s+'%' //左匹配
else if RightStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s //右匹配
else
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s+'%'; //中间匹配 end;
ADOQuery1.Prepared;
ADOQuery1.Open ;end;
end;
我在uses 里已经引用了adodb的;procedure Tcjcx_fr.mh_btClick(Sender: TObject);
var s:string;
begin
with stuxinxi_Dm do
begin
s:=quotedstr(trim(gjz_ed.text));
adoquery1.Close;
adoquery1.SQL.Clear;
case mhtj_rg.ItemIndex of
//0:按姓名搜索;1:按课程名搜索 0:adoquery1.SQL.Add('Select * From chengjibiao where stu_no in(select stu_no from xuejibiao where stu_name Like :str');
//分姓名的3种输入情况搜索成绩表
if LeftStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:=s+'%' //左匹配
else if RightStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s //右匹配
else
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s+'%'; //中间匹配 1:adoquery1.SQL.Add('Select * From chengjibiao where kecheng_no in(select kecheng_no from kechengbiao where kecheng_name Like :str');
//分课程名的3种输入情况搜索成绩表
if LeftStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:=s+'%' //左匹配
else if RightStr(s,1)<>'' then
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s //右匹配
else
ADOQuery1.SQL.ParamByName('str').AsString:='%'+s+'%'; //中间匹配 end;
ADOQuery1.Prepared;
ADOQuery1.Open ;end;
end;
解决方案 »
- DBGRID循环取值
- 散分啰,过年以后结贴~~~~~~~~~~
- 求SQL,望大侠们指点分不够开帖另加
- 用CoolTrayIcon怎么实现启动最小化到系统托盘?????
- 如何把一个SQL文件恢复为数据库
- 我用delphi的db数据库,新添记录时,日期字段如何不许和以前的重复.
- 各位cs侠,请看我的另类问题系列(一)--About table TQuery and dbgrid
- 如何动态创建菜单的问题!
- 如何获取网站页面的内容?
- 关于窗体的FormStyle的问题
- 请问如何时时监控windwos应用程序,获取当前所运行的程序的信息
- 请了各位老大:最近我的新机总是在一上网时就罢工,是不是跟主板上的超线程有关
procedure TForm2.FlatEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
if flatedit1.Text='' then
application.MessageBox('您没有输入关键字!','给您的提示',mb_ok+MB_ICONEXCLAMATION )
else
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from 内容 where 内容 like :aa');
adoquery1.Parameters.ParamByName('aa').Value:='%'+flatedit1.Text+'%';
adoquery1.Open;
showmessage('找到满足条件的记录数: '+inttostr(adoquery1.RecordCount)+'条');
flatedit1.Text:='';
end;
end;
NameStr:String;∥设置字符串中间变量
Begin
NameStr:=′王′;
Query1SQLClear{清除SQL属性中的SQL命令语句}
Query1SQLAdd(′Select*FromCustomdbwhere(Name1>=N1)and(Name2<=N2)′);∥SQL命令语句
Query1params[0]AsString:=NameStr+chr(0);∥控制参数在NameStr+Chr(0)
Query1params[1]AsString:=NameStr+chr($ff);∥和NameStr+Chr($ff)之间
Query1Open;∥打开数据库,执行SQL查询
End;
这样不对
ADOQuery1.fieldByName('str')
你认为我的if语句对吗?你的还只是我其中的一种情况吧。
我的case语句都没执行,是否是因为我把radiogroup组件放在了groupbox里呢
procedure Tcjcx_fr.zhtj_btClick(Sender: TObject);
begin
with stuxinxi_Dm do
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
adoquery1.SQL.Add('select t_cj.*, stu_name,zhuanye_name,kecheng_name');
adoquery1.SQL.Add('from chengjibiao t_cj,xuejibiao t_xj,zhuanyemb t_zy,kechengbiao t_kc');
adoquery1.SQL.Add('where t_cj.stu_no=t_xj.stu_no and t_xj.stu_name like :str1');
ADOQuery1.Parameters.ParamByName('str1').value:='%'+xm_ed.Text+'%';
adoquery1.SQL.Add('and t_cj.kecheng_no=t_kc.kecheng_no and t_kc.kecheng_name like :str2');
ADOQuery1.Parameters.ParamByName('str2').value:='%'+kcm_cb.Text+'%';
adoquery1.SQL.Add('and t_zy.zhuanye_no=t_kc.zhuanye_no and t_zy.zhuanye_name like :str3');
ADOQuery1.Parameters.ParamByName('str3').value:='%'+zy_cb.Text+'%';
ADOQuery1.Prepared;
try
ADOQuery1.Open;
except
ADOQuery1.ExecSQL;
end;
end;
end;