Project Project1.exe raised exception class EOLeException with message"不能将值NULL插入列‘StockID',表"POS.dbo.Stock";列不允许有空值。INSERT失败。“Process stopped。Use Step or Run to continue。
解决方案 »
- cxVerticalGrid中ComboBox的index值
- 自写日期控件,怎样实现TDateTimePicker的下拉效果
- 太怪了,出鬼了,字段为中文就OK,英文就不行???
- 简单问题,大家帮忙看看!~
- 创建一个带有CheckBox的TreeView,如何获得OnCheck消息呢?
- 如何获取某台机子sqlserver的所有数据库名
- 怎样把查询后的数据(access)(控件是adoquery,datasource)存成excel文件?急!
- 如果在运行时就给定的一个类得知它分别有哪些属性?
- 关于单步调试的低级问题
- 如何执行外部程序?这个程序是一个DOS形式的程序,它需要二个参数,DOS下的执行如: ExeFile InFile OutFile
- delphi里有没有类似属性控件的组件?
- 高手帮忙看看工程里面缺少imled.dcu该怎么办?
如果数据重要,则一定要先给 StockID赋值 。
试试
if ISNULL(DATA) then
insert into (StockID) values('')
else
insert into (StockID) values(DATA)
with ADOQuery2 do
begin
close;
sql.clear;
sql.add('select top 1 * from Stock order by StockID desc');
open;
first;
if fieldbyname('StockDate').asstring=datetostr(Date) then
edit1.text:=floattostr(fieldbyname('StockID').asfloat+1)
else
edit1.text:=floattostr(strtofloat(formatdatetime('yyyy""mm""dd',Date))*10000+1); end; with ADOQuery1 do
begin
close;
sql.clear;
sql.add('select * from Stock where StockID='+''''+edit1.text+'''');
open;
first;
end;end;procedure TStockFrm.Button4Click(Sender: TObject);
begin
StockFrm.hide;
end;procedure TStockFrm.Button1Click(Sender: TObject);
begin
if dbcombobox1.text='' then
showmessage('请选择供货商!')
else
if dbcombobox2.text='' then
showmessage('请选择入库货品!')
else
if dbedit4.text='' then
showmessage('请填写入库数量!')
else
if dbedit5.text='' then
showmessage('请填写入库单价!')
else
begin
with ADOQuery2 do
begin
close;
sql.clear;
sql.add('insert into Stock (StockID,StockDate,FeederName,ProductName,');
sql.add('ProductCode,Spec,Unit,RFStockPrice,UnitPrice,Quantity,Payment)values (' );
sql.add(''''+edit1.text+''''+','+''''+edit2.text+''''+',');
sql.add(''''+dbcombobox1.text+''''+','+''''+dbcombobox2.text+''''+',');
sql.add(''''+dbcombobox3.text+''''+','+''''+dbedit1.text+''''+',');
sql.add(''''+dbedit2.text+''''+','+''''+dbedit3.text+''''+',');
sql.add(''''+dbedit4.text+''''+','+''''+dbedit5.text+''''+',');
sql.add(''''+dbedit6.text+''''+')');
execsql;
end;
with ADOQuery1 do
begin
close;
sql.clear;
sql.add('select * from Stock where StockID='+''''+edit1.text+'''');
open;
first;
end;
showmessage('此货品添加成功!');
end;
大概的程序是这样的,,哪位高手帮帮忙啊,我看到有INSERT的就这个了
首先是你插入到stockid的值是空的,因为stockid没插入成功,所以列stockid出现空值,导致了INSERT失败,程序崩溃。
由此可见主要就是因为插入stockid的值为空造成的,从这条思路找下去
我估计可能是因为楼主设置的StockID字段类型跟你取值方式不符。可能你StockID字段是整形的,但你取值时是用float取的。
edit1.text:=floattostr(fieldbyname('StockID').asfloat+1)
if ***.text='' then
showmessage('.....')
做个判断当为空是改为0