我用ADO连接SQL Server2000,在用TADOQuery插入数据时出现错误提示
Row cannot be located for updating.Some values may have been changed since it was last read.
但数据却插入到数据库中了。TDBGrid中也显示出来了。怎么回事?怎么解决?
表中有主索引,cachesize也设置为1
Row cannot be located for updating.Some values may have been changed since it was last read.
但数据却插入到数据库中了。TDBGrid中也显示出来了。怎么回事?怎么解决?
表中有主索引,cachesize也设置为1
这ADO一旦不顺,就是不顺,它许多限制:要有主键[不重复的索引],
光有索引还不行.如果记录中不小心有两行完全一样的记录,就无法操作这两
行,删也不行.
MainForm->ADOReCataQuery->FieldByName("IdDirectory")->AsInteger=MainForm->ADOReDirQuery->FieldByName("IdDirectory")->AsVariant;
MainForm->ADOReCataQuery->FieldByName("IdCatalog")->AsInteger=ADOReCataName->Parameters->operator [](7)->Value;
MainForm->ADOReCataQuery->FieldByName("TheYear")->AsInteger=MainForm->theYear;
MainForm->ADOReCataQuery->FieldByName("TheMonth")->AsInteger=MainForm->theMonth;
MainForm->ADOReCataQuery->FieldByName("Num")->AsInteger=StrToInt(Edit1->Text);
MainForm->ADOReCataQuery->FieldByName("DatumName")->AsString=Edit2->Text;
MainForm->ADOReCataQuery->FieldByName("Material")->AsString=Edit3->Text;
MainForm->ADOReCataQuery->FieldByName("Type")->AsString=Edit4->Text;
if(Edit5->Text!="")
MainForm->ADOReCataQuery->FieldByName("MaxSave")->AsInteger=StrToInt(Edit5->Text);
if(Edit6->Text!="")
MainForm->ADOReCataQuery->FieldByName("MinSave")->AsInteger=StrToInt(Edit6->Text);
if(Edit7->Text!="")
MainForm->ADOReCataQuery->FieldByName("Price")->AsFloat=StrToFloat(Edit7->Text);
MainForm->ADOReCataQuery->FieldByName("Unit")->AsString=Edit8->Text; if(Edit9->Text!="")
MainForm->ADOReCataQuery->FieldByName("BalNum")->AsFloat=StrToFloat(Edit9->Text); if(Edit10->Text!="")
MainForm->ADOReCataQuery->FieldByName("BalMemory")->AsFloat=StrToFloat(Edit10->Text);
if(CheckBox1->Checked)
{
if(Edit9->Text!="")
MainForm->ADOReCataQuery->FieldByName("YearBalNum")->AsFloat=StrToFloat(Edit9->Text);
if(Edit10->Text!="")
MainForm->ADOReCataQuery->FieldByName("YearBalMemory")->AsFloat=StrToFloat(Edit10->Text);
}
else
{
if(Edit11->Text!="")
MainForm->ADOReCataQuery->FieldByName("YearBalNum")->AsFloat=StrToFloat(Edit11->Text);
if(Edit12->Text!="")
MainForm->ADOReCataQuery->FieldByName("YearBalMemory")->AsFloat=StrToFloat(Edit12->Text);
}
MainForm->ADOReCataQuery->Post();
[IdDirectory] [bigint] NOT NULL ,
[IdCatalog] [bigint] NOT NULL ,
[TheYear] [int] NOT NULL ,
[TheMonth] [int] NOT NULL ,
[Num] [int] NOT NULL ,
[DatumName] [varchar] (16) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Material] [varchar] (10) COLLATE Chinese_PRC_CI_AS NULL ,
[Type] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[MaxSave] [int] NULL ,
[MinSave] [int] NULL ,
[Price] [decimal](4, 0) NULL ,
[Unit] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[BalNum] [money] NULL ,
[BalMemory] [money] NULL ,
[AddNum] [money] NULL ,
[SubNum] [money] NULL ,
[AddMemory] [money] NULL ,
[SubMemory] [money] NULL ,
[YearAddNum] [money] NULL ,
[YearSubNum] [money] NULL ,
[YearAddMemory] [money] NULL ,
[YearSubMemory] [money] NULL ,
[YearBalNum] [money] NULL ,
[YearBalMemory] [money] NULL ,
[TotalAddNum] [money] NULL ,
[TotalSubNum] [money] NULL ,
[TotalAddMemory] [money] NULL ,
[TotalSubMemory] [money] NULL ,
[Many] [int] NULL ,
[FirstAdd] [int] NULL
) ON [PRIMARY]
我遇到过这问题
行无法定位。某些记录可能在最后读取时改变。我也碰到好几次这样的问题。每次原因都不一样。
主要是程序有问题。自己找吧。
曾经有一次我化了一天才解决了这个问题。
祝你好运!