比如:类型表:
ID,intType
1 1
2 2
3 3
其中我用sql语句查询后,类型不知算不算变了?之后修改就出错?adoquery1.sql.clear
adoquery1.sql.text:='select case when intTYpe=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' as intType1 from 类型表'
adoquery1.open
以上查询,不知道是不是将源字段暂时变为字符串类型了.
我执行下面就出错if not adoquery1.eof then
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType1').value=5;
adoquery1.post;
end;
end;执行以上语句就会出现:
Field 'intType1' cannot be modified.
不知道是怎么回事?
ID,intType
1 1
2 2
3 3
其中我用sql语句查询后,类型不知算不算变了?之后修改就出错?adoquery1.sql.clear
adoquery1.sql.text:='select case when intTYpe=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' as intType1 from 类型表'
adoquery1.open
以上查询,不知道是不是将源字段暂时变为字符串类型了.
我执行下面就出错if not adoquery1.eof then
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType1').value=5;
adoquery1.post;
end;
end;执行以上语句就会出现:
Field 'intType1' cannot be modified.
不知道是怎么回事?
解决方案 »
- 高难度的fastreport报表,请高手指教
- [复仇贴]悬赏1000分屠549
- 请问大家发布程序的时候是怎么处理AADO 的呢?
- ADOTable在放置在Remote data modules中居然不能用?????
- 一个简单问题:如何进行格式化输出?在线等。
- 关于Delphi中记录的定位问题,有点不太习惯,希望大家来讨论
- 如何设置PrintDBGridEh1.AfterGridTexT.Text的字体
- 那位大侠有delphi进销存的源码,我愿意用一套PB的企业管理系统源码交换,学习用!
- 我又有新任务了,今晚要吧控制鼠标键盘解决呀,敬请各位相助!!
- 急!哪里有Dx系列的控件下载?
- 怎么连接sql2000数据库并进行session验证,急!
- 循环错误题(补题)
adoquery1.sql.text:='select case when intTYpe=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' as intType1 from 类型表'
adoquery1.open
--
adoquery1.sql.clear
adoquery1.sql.text:='select case when intTYpe=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' end as intType1 from 类型表'
adoquery1.open
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType1').value=5;
adoquery1.post;
end;
end;---------
if not adoquery1.eof then
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType1')).value='5'; adoquery1.post;
end;
end;
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType1')).Asstring='5';
adoquery1.post;
end;
end;
if not adoquery1.eof then
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType1').value=5;
adoquery1.post;
end;
end;数据库中根本不存在intType1怎么能保存呢
你应该把类型做个基础表,做为关联,这才是解决你程序中的方法。
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('intType').asstring='5';
adoquery1.post;
end;
end;也不行!
begin
if adoquery1.state in [dsInsert,dsEdit] then
begin
adoquery1.fieldbyname('iT').value=5;
adoquery1.post;
end;
end; 现在可以了,我将显示跟原字段分开显示就可以了。
不过感觉这样怪怪的
2.在修改时要修改真实字段 With ADOQuery1 do
begin
Close;
Sql.Clear;
sql.Text:='select IntType,case when intTYpe=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' end as intType1 from Test' ;
Open;
end;
然后再对真实字段IntType进行修改!
adoquery1.fieldbyname('intType').asstring:='2';//intType是源或真实字段,intType1为虚拟字段
adoquery1.post;
sql.Clear;
sql.Add('select case when intType=1 then ''类型一'' when intType=2 then ''类型二'' when intType=3 then ''类型三'' end as inttype1 from test ');
open;
按照LZ的意思,我一样写了个测试代码,怎么运行老是显示CASE查询表达式语法出错,请各位大老赐教,谢谢!