在save()中:
...
DataSet.Append;
EditDate.Text:=DateToStr(theDate);//《---赋了值了呀?
EditSectionOffice.Text:=theOffice;for intCount:=0 to Self.ComponentCount-1 do
if (self.Components[intCount] is TEdit) then
begin
strField:=self.Components[intCount].Name;
strField:='sp'+Copy(strField,5,Length(strField)-4);
FieldValues[strField]:=(self.Components[intCount] as TEdit).Text;
Post;
end;{if self.Components[intCount] is TEdit }
...报错如下:spDate不允许插入空值。
怎么会这样呢?
...
DataSet.Append;
EditDate.Text:=DateToStr(theDate);//《---赋了值了呀?
EditSectionOffice.Text:=theOffice;for intCount:=0 to Self.ComponentCount-1 do
if (self.Components[intCount] is TEdit) then
begin
strField:=self.Components[intCount].Name;
strField:='sp'+Copy(strField,5,Length(strField)-4);
FieldValues[strField]:=(self.Components[intCount] as TEdit).Text;
Post;
end;{if self.Components[intCount] is TEdit }
...报错如下:spDate不允许插入空值。
怎么会这样呢?
解决方案 »
- TChart如何添加滚动条
- 求教:关于程序中ADOConnection的问题!
- 为何这样不行
- 急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~~~~~~~~@@@@@@@@@@
- 求援!!!我使用DBgrideh连了一个数据表,并显示,我想双击表中的一条记录,并使该记录的背景变成另一个指定颜色!怎么做?在线等!!!
- quickreport如何将一条纪录打印到几个页面上
- 动态ADO连接
- 小问题!散分
- (急)将VB代码变成DELPHI6.0的问题???
- DBlookupcombobox等的问题?
- 如何将一个GMT时间格式字符串转换成系统本地时间?
- websnap生成的DLL执行中的很奇怪问题
如果有日期值,那么你数据表的spDate字段真的是string类型么?还是DateTime类型?
Note: This code does not save the form or data module to disk after the nonvisual components are moved. If executed at runtime, the effect will not persist.var I: Integer;
Temp: TComponent;
begin
for I := ComponentCount - 1 downto 0 do
begin
Temp := Components[I];
if not (Temp is TControl) then
begin
RemoveComponent(Temp);
DataModule2.InsertComponent(Temp);
end;
end;end;
所以在这个地方DataSet.Append;你已经出错的,不信你自己设个断点试试。
因为你用无参数的Append,也就是所有的字段都未赋值,spDate的命运当然相同,所以如果你想Append一条记录,必须用带参数的Append,必须给那些非空的字段赋一个缺省值(随便一个合法的值都可),反正你在随后的代码中要赋值的,
要不你先把所有的值都计算完成后再用带参数的Append(...)把这条记录追加上去。
if (self.Components[intCount] is TEdit) then
begin
strField:=self.Components[intCount].Name;
strField:='sp'+Copy(strField,5,Length(strField)-4);
//加上这条看看是不是真的有值啊
ShowMessage((self.Components[intCount] as TEdit).Text);
//加上这条看看是不是真的有值啊
FieldValues[strField]:=(self.Components[intCount] as TEdit).Text;
Post;
end;{if self.Components[intCount] is TEdit }还有FieldValues[spDate]是什么类型的字段啊?你往里面赋String类型?