procedure TFrmShebeiIn.ComboBox9Exit(Sender: TObject);
var
TmpAdodateset : TADODataSet;
begin
if not CheckHaveClientBuMen(Trim(combobox9.text)) then
begin
if Application.MessageBox('在客户系统没有此客户!' + #13#10 +
'是否作为临时客户?','提示',MB_YESNO) = IDYES then
begin
TmpAdodateset := TADODataSet.Create(self);
try
TmpAdodateset.Connection := FrmShebeiMain.ADOConnection1;
TmpAdodateset.Active := false;
TmpAdodateset.CommandText := 'select 单位客户编号,单位客户名称 from 客户_单位客户信息表' + #13#10 +
' where 1=2';
TmpAdodateset.Active := true;
TmpAdodateset.Open;
TmpAdodateset.FieldByName('单位客户编号').AsString := 'ls00000' ;
TmpAdodateset.FieldByName('单位客户名称').AsString := Trim(combobox9.Text);
TmpAdodateset.FieldByName('客户性质').AsInteger := 1;
TmpAdodateset.Post;
TmpAdodateset.Active := false;
except
TmpAdodateset.Active := false;
TmpAdodateset.Free;
Application.MessageBox('无法添加临时客户!','提示',MB_OK);
end;
end
else
begin
combobox9.itemindex := -1;
combobox9.text := '';
Application.MessageBox('请先在客户系统中输入该单位信息', '提示', MB_OK);
end
end;
end;为什么上面老报错呀,大哥们帮小弟看看呀,
var
TmpAdodateset : TADODataSet;
begin
if not CheckHaveClientBuMen(Trim(combobox9.text)) then
begin
if Application.MessageBox('在客户系统没有此客户!' + #13#10 +
'是否作为临时客户?','提示',MB_YESNO) = IDYES then
begin
TmpAdodateset := TADODataSet.Create(self);
try
TmpAdodateset.Connection := FrmShebeiMain.ADOConnection1;
TmpAdodateset.Active := false;
TmpAdodateset.CommandText := 'select 单位客户编号,单位客户名称 from 客户_单位客户信息表' + #13#10 +
' where 1=2';
TmpAdodateset.Active := true;
TmpAdodateset.Open;
TmpAdodateset.FieldByName('单位客户编号').AsString := 'ls00000' ;
TmpAdodateset.FieldByName('单位客户名称').AsString := Trim(combobox9.Text);
TmpAdodateset.FieldByName('客户性质').AsInteger := 1;
TmpAdodateset.Post;
TmpAdodateset.Active := false;
except
TmpAdodateset.Active := false;
TmpAdodateset.Free;
Application.MessageBox('无法添加临时客户!','提示',MB_OK);
end;
end
else
begin
combobox9.itemindex := -1;
combobox9.text := '';
Application.MessageBox('请先在客户系统中输入该单位信息', '提示', MB_OK);
end
end;
end;为什么上面老报错呀,大哥们帮小弟看看呀,
解决方案 »
- 在程序运行期,如何动态复制控件?
- Delphi 三层中 服务器 如何不定时的向 客户端 广播消息?
- 如何捕捉webbrowser里的键盘事件??
- RemoveMenu怎么没用??
- 当我对adoquery1 post 时,出现错误:Row cannot be located for updating。Some values may have been changed since it was last read.
- 高手请进
- 调查一下:当程序员的你,是否害怕病毒呢?
- 如何用程序修改或者添加EXE的资源?
- 我想学编写游戏!
- 怎样横向打印窗体,分不够可以再加
- XDJM们,这几天挣了好几十分了,可为什么可用分不长啊?
- 打印机有2个出纸口,有没有办法控制从哪个出纸口输出啊
..
else
begin
combobox9.itemindex := -1;
combobox9.text := '';
Application.MessageBox('请先在客户系统中输入该单位信息', '提示', MB_OK);
end;<-------------------
end;
TmpAdodateset.Open;
TmpAdodateset.Append;<---------------
但是报错说没有找到,TmpAdodateset.FieldByName('客户性质').AsInteger := 1; 客户性质这个字段,明明库里有这个字段呀,
ADOQuery.SQL.Add('Insert into tablename(field1, field2,..) values(值1, 值2, ...)');
ADOQuery.ExecSQL;
TmpAdodateset.Open;你把这两句放一起干嘛?都是一个意思啊,只要用一句就可以了
谢谢指点,马上改正;
to jianghd(天天)
你的方法很简单,很好!谢谢提供,
今天下午结贴。