delphi最基础的SQL查询 - Delphi / 数据库相关
我要查询X表中 收入 = Y的 字段
比如 我在SQL中 是这么输入的 slect * from X where 收入 = y
在delphi 中 y 就用edit1.text里输入
begin
adoquery1.Close;
ADOQuery1.SQL.Clear;
adoquery1.SQL.Add('select * from xmb where 收入='+''''+trim(edit1.Text)+'''');
try
adoquery1.open;
except
showmessage('没有该收入记录');
exit;
end;
这段断码的话,如果收入文本的可以执行 ,但如果收入是数值的 应该怎么修改代码!
请各位大虾指教!
注意:收入字段是数字型
好结帐了
建议这么写:
adoquery1.SQL.Add('select * from xmb where 收入:= earn')
adoquery1.Parameters.ParamValues['earn'] := trim(edit1.Text);
同意3楼的
delphi当时课设都没怎么做,哎。。。
来结账了
相关问答:
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......
例子程序见附件,用Delphi 7进行编译
问题代码为
Delphi(Pascal) code:
if Node.ChildNodes <> nil then
begin
for i := 0 to Node.ChildNodes.Count - 1 do
begin
cNode := N ......
我觉得mysql和sqlserver有共同的地方:
有个问题是关于表的锁问题:
进程A 进程B
select * from user where id in lock share mode(共享锁)
&nb ......
有这样一条SQL
Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......
原SQL语句SQL code:
SELECT t6.FName '操作工',t1.FDate '日期',t5.FName '制单人',t3.FName '设备',t4.FName '班制',
t7.FBillNo '工艺指令单号',t8.FName '岗位',t2. ......