dm.addQpremoney.Close;
dm.addQpremoney.SQL.Clear;
dm.addQpremoney.SQL.Add('select max(jknumberid) as ID from premoney');
dm.addQpremoney.SQL.Add('where inhoscode='''+trim(edit2.Text)+'''');
dm.addQpremoney.Open;就是当找不到符合条件的记录时,我用showmessage(inttostr(dm.addQpremoney['id'])会出错,但现在我只想用sql语句实现此功能:如果找不到该记录的时候,就把ID的值初始化为“1”,当找到该符合条件的记录时,就取其最大的值,这条语句该怎么写??(注:只能用语句实现可以吗??也就是不用dm.addqpremoney.recordcount 等来判断)
dm.addQpremoney.SQL.Clear;
dm.addQpremoney.SQL.Add('select max(jknumberid) as ID from premoney');
dm.addQpremoney.SQL.Add('where inhoscode='''+trim(edit2.Text)+'''');
dm.addQpremoney.Open;就是当找不到符合条件的记录时,我用showmessage(inttostr(dm.addQpremoney['id'])会出错,但现在我只想用sql语句实现此功能:如果找不到该记录的时候,就把ID的值初始化为“1”,当找到该符合条件的记录时,就取其最大的值,这条语句该怎么写??(注:只能用语句实现可以吗??也就是不用dm.addqpremoney.recordcount 等来判断)
解决方案 »
- 正方形的image1中加入一个长方型的JPG,image1.Proportional:=true..
- quickreport的输出问题
- 如何取字符串的内容?
- 关于表单的先后顺序
- 如何截获或去掉socket的出错信息?
- 各位老大,哪有delphi6 update2下载啊。来者有份
- VirtualTrees控件里如果设置多级节点如何设计数据库(例如:高一年级,高一01班,高一01班全体,高一01班在籍)
- 请问如何实现以下对文件的操作
- 请问各位前辈:你们是如何用控件连接SQL数据库的?
- win2000 怎么设置桌面主题?我没看到哪里能安装嘛
- 设置窗体居中的方法
- 我遇到两个简单的问题,各位高手快来帮忙
showmessage(VARtostr(dm.addQpremoney['id'])
dm.addQpremoney.SQL.Add('where inhoscode='''+trim(edit2.Text)+''' and jknumberid is not null');
...if not dm.addQpremoney.fields[0].IsNull then
showmessage(inttostr(dm.addQpremoney['id'])
SQL.Add('select isnull(max(jknumberid),1) as ID from premoney');
showmessage(dm.addQpremoney['id'].AsString)
dm.addQpremoney.SQL.Clear;
dm.addQpremoney.SQL.Add('select isnull(max(jknumberid),1) as ID from premoney');
dm.addQpremoney.SQL.Add('where inhoscode='''+trim(edit2.Text)+'''');
dm.addQpremoney.Open;
showmessage(inttostr(dm.addQpremoney['id']));
是这样还不行??是不是在paradox7的数据库那里不支持呢???可能各位大侠都是在
SQL SERVER里面实现的吧。
dm.addQpremoney.SQL.Add('select max(jknumberid) as ID from premoney');
dm.addQpremoney.SQL.Add('where inhoscode='''+trim(edit2.Text)+''' and jknumberid <> null');
估计大家都说的是SQLServer
ID的值初始化为“1”;
else
取其最大的值;