Z
zgl198171
Unregistered / Unconfirmed
GUEST, unregistred user!
我查了很多资料就是不能解决问题啊,所以请教各位哥哥帮我查一下,不甚感激!
下面的程序完成创建表.
添加字段程序快:
procedure TFrm_GSFactorSet.Button1Click(Sender: TObject);
var
FieldPtrFieldRec;
begin
new(FieldPtr);
FieldPtr^.Name:=Trim(Edit3.Text);
FieldPtr^.FType:=Trim(ComboBox2.Text);
FieldPtr^.FNumber:=StrToInt(MaskEdit1.text);
FieldPtr^.IsNull:=CheckBox1.Checked;
//初始Len为1
SetLength(FieldRec,Len);
FieldRec[len-1]:=FieldPtr
//有没有错?????
INC(Len);
dispose(FieldPtr);
Edit3.Text:='';
Edit3.SetFocus;
end;
测试块:
var
I:integer;
begin
For I:=Low(FieldRec) to High(FieldRec) do
begin //有错,得不到正确的结果
ShowMessage(FieldRec^.name)
// +'_'+(FieldRec^).FType
end;
end;
保存模块:
procedure TFrm_GSFactorSet.Button2Click(Sender: TObject);
var
aq:TADOQUery;
i:Integer;
begin
aq:=TADOQuery.Create(nil);
aq.Connection:=MYDM.ADOConnection1;
Try
aq.Close;
aq.SQL.Clear;
aq.SQL.Add('Create Table '+' '+edit1.Text);
aq.SQL.Add('(');
For i:=Low(FieldRec) to High(FieldRec)-1 do
begin
if (FieldRec)^.IsNull then
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Null'+',')
else
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Not Null'+',') ;
end;
i:=High(FieldRec);
if (FieldRec)^.IsNull then
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Null')
else
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Not Null') ;
aq.SQL.Add(')') ;
aq.ExecSQL;
showmessage('创建表成功!')
except
end;
end;
下面的程序完成创建表.
添加字段程序快:
procedure TFrm_GSFactorSet.Button1Click(Sender: TObject);
var
FieldPtrFieldRec;
begin
new(FieldPtr);
FieldPtr^.Name:=Trim(Edit3.Text);
FieldPtr^.FType:=Trim(ComboBox2.Text);
FieldPtr^.FNumber:=StrToInt(MaskEdit1.text);
FieldPtr^.IsNull:=CheckBox1.Checked;
//初始Len为1
SetLength(FieldRec,Len);
FieldRec[len-1]:=FieldPtr
//有没有错?????
INC(Len);
dispose(FieldPtr);
Edit3.Text:='';
Edit3.SetFocus;
end;
测试块:
var
I:integer;
begin
For I:=Low(FieldRec) to High(FieldRec) do
begin //有错,得不到正确的结果
ShowMessage(FieldRec^.name)
// +'_'+(FieldRec^).FType
end;
end;
保存模块:
procedure TFrm_GSFactorSet.Button2Click(Sender: TObject);
var
aq:TADOQUery;
i:Integer;
begin
aq:=TADOQuery.Create(nil);
aq.Connection:=MYDM.ADOConnection1;
Try
aq.Close;
aq.SQL.Clear;
aq.SQL.Add('Create Table '+' '+edit1.Text);
aq.SQL.Add('(');
For i:=Low(FieldRec) to High(FieldRec)-1 do
begin
if (FieldRec)^.IsNull then
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Null'+',')
else
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Not Null'+',') ;
end;
i:=High(FieldRec);
if (FieldRec)^.IsNull then
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Null')
else
aq.SQL.Add((FieldRec)^.name+' '+(FieldRec)^.FType+'('+inttostr((FieldRec)^.Fnumber)+' '+' Not Null') ;
aq.SQL.Add(')') ;
aq.ExecSQL;
showmessage('创建表成功!')
except
end;
end;