L
lqh
Unregistered / Unconfirmed
GUEST, unregistred user!
我在SQL中建了两个表,一个表salary,另一个为gzbxx;我想在delphi5.0中新建一个表,该表结构与salary一样,同时它又是表gzbxx的一条记录,程序如下:
var
str_mc,str_sm,str_cjr:string;
table2.DisableConstraints ;
table1.DisableConstraints ;
str_mc:=dbedit1.Text ;
str_sm:=dbedit2.Text ;
str_cjr:=dbedit3.Text ;
table2.close;
table2.Open;
table3.FieldDefs.Assign(table2.fielddefs);
table3.TableName:=str_mc;
table3.Createtable;
table2.EnableConstraints ;
table1.Open;
table1.Edit;
table1.append;
table1.FieldByName('工资表名称').asstring:=str_mc;
table1.FieldByName('工资表说明').asstring:=str_sm;
table1.FieldByName('创建人').asstring:=str_cjr;
cjrq1.Value :=now;
table1.post;
dbedit1.Clear;
dbedit2.Clear;
edit3.Clear;
dbedit3.Clear;
table1.EnableConstraints ;
结果post 是出现错误:table not in a unique indexed.
please 指教.
var
str_mc,str_sm,str_cjr:string;
table2.DisableConstraints ;
table1.DisableConstraints ;
str_mc:=dbedit1.Text ;
str_sm:=dbedit2.Text ;
str_cjr:=dbedit3.Text ;
table2.close;
table2.Open;
table3.FieldDefs.Assign(table2.fielddefs);
table3.TableName:=str_mc;
table3.Createtable;
table2.EnableConstraints ;
table1.Open;
table1.Edit;
table1.append;
table1.FieldByName('工资表名称').asstring:=str_mc;
table1.FieldByName('工资表说明').asstring:=str_sm;
table1.FieldByName('创建人').asstring:=str_cjr;
cjrq1.Value :=now;
table1.post;
dbedit1.Clear;
dbedit2.Clear;
edit3.Clear;
dbedit3.Clear;
table1.EnableConstraints ;
结果post 是出现错误:table not in a unique indexed.
please 指教.