procedure TDBTreeView_1.AddButtonClick(Sender: TObject);
var
Node, NewNode: TTreeNode;
NewCode, NewID: string;
begin
if FTree.Selected=nil then exit;
Node:= FTree.Selected.Parent;
Frm_EditForm:= TFrm_EditForm.Create(Self);
with Frm_EditForm do
begin
Pnl_MCode.Caption:= Node.Text;
Pnl_Code.Caption:= GetNewCode;
if ShowModal= mrOK then
begin
with TADOQuery(DataSource.DataSet) do
begin
LockType:= ltOptimistic;
DisableControls;
try
Append;
FieldByName(DataField).AsString:= NewID;
FieldByName(FDataOperation.FMcCode).AsString:= NewCode;
FieldByName(FDataOperation.FMcData).AsString:= LblEdit_Name.Text;
UpdateBatch;
NewNode:= FTree.Items.AddChild(Node, LblEdit_Name.Text)
end;
NewNode.SelectedIndex:= 2;
NewNode.StateIndex:= 1;
Showmessage(GetNodeStr(NewNode));//在这里出错,查看数据库,新增数据已经添加到表中,但还是会出现错误,说数据集处于Eof或Bof位置,
except
end;
EnableControls;
end;
end;
end;
end;
function TDBTreeView_1.GetNodeStr(Node: TTreeNode): string;
var
p: PString;
begin
if Node= nil then exit;
p := Node.Data;
Result := p^;
end;
var
Node, NewNode: TTreeNode;
NewCode, NewID: string;
begin
if FTree.Selected=nil then exit;
Node:= FTree.Selected.Parent;
Frm_EditForm:= TFrm_EditForm.Create(Self);
with Frm_EditForm do
begin
Pnl_MCode.Caption:= Node.Text;
Pnl_Code.Caption:= GetNewCode;
if ShowModal= mrOK then
begin
with TADOQuery(DataSource.DataSet) do
begin
LockType:= ltOptimistic;
DisableControls;
try
Append;
FieldByName(DataField).AsString:= NewID;
FieldByName(FDataOperation.FMcCode).AsString:= NewCode;
FieldByName(FDataOperation.FMcData).AsString:= LblEdit_Name.Text;
UpdateBatch;
NewNode:= FTree.Items.AddChild(Node, LblEdit_Name.Text)
end;
NewNode.SelectedIndex:= 2;
NewNode.StateIndex:= 1;
Showmessage(GetNodeStr(NewNode));//在这里出错,查看数据库,新增数据已经添加到表中,但还是会出现错误,说数据集处于Eof或Bof位置,
except
end;
EnableControls;
end;
end;
end;
end;
function TDBTreeView_1.GetNodeStr(Node: TTreeNode): string;
var
p: PString;
begin
if Node= nil then exit;
p := Node.Data;
Result := p^;
end;
解决方案 »
- 求大神救 [Error] Unit2.pas(1160): Incompatible types: 'String' and 'Integer'
- Accept 提取对方端口号?
- 高分求杨勇写的snpack2.25版for delphi6
- 怎样判断目录是否存在
- 超过integer范围的浮点数如何取整?
- 为什么日期型字段不能精确到毫秒级?
- 在线等待:我的Locate()错在何处?急急急!
- 怎样在imgedit1中显示paradox数据库中的图形字段中的图象呢?
- 有谁在“鲨鱼丸”(www.whatisnet.net)下过东西吗?要怎么下啊?
- 如何调整TRichEdit的行间距?
- 图像格式转换,在线等,急需
- 求算法 设计思想 将下表A更新后得到表B的结果???各位兄弟帮忙啊
后面 加一个 post 看看
前加个
FTree.setfocus;
看看
var
p: PString;
begin
if Node= nil then exit;
p := Node.Data;
Result := p^;//其实真正的错误是在这里,错误信息:“Project Project1.exe
//raised exception class EAccessViolation with message
//'Access violation at address 0059BA7B in module' Project1.exe'.
//Read of address 00000000'.Process stopped. Use Step or Run to continue;
end;
data:Pstring;
begin
...
NewNode:= FTree.Items.AddChild;
NewNode.Caption :=Node;
new(data);
data := PString(@LblEdit_Name.Text);
NewNode.Data := data;
...
按你的方法修改了,但还是不行