【发布时间】:2016-12-13 01:44:40
【问题描述】:
我将新订单详细信息添加到我的数据库中的表中。
其中一列名为email,在我创建的表单中,我在我的delphi应用程序和随后的db中添加新订单,我使用TEdits来传递数据。
这是代码:
procedure TForm2.actAddComandaExecute(Sender: TObject);
begin
if dbmodule.comenziConnection.Connected then
begin
if addOrderForm.ShowModal=mrok then
begin
dbmodule.comenziQuery.SQL.Clear;
dbmodule.comenziQuery.SQL.Add( 'insert into `r33758pi_tipotask`.`comenzi` ( stare, client, telefon, email, detalii, livrare, pret, user, status, observatii ) values ( :stare, :client, :telefon, :email, :detalii, :livrare, :pret, :user, :status, :observatii ) ' ) ;
dbmodule.comenziQuery.Params.ParamByName( 'stare' ).AsString := addOrderForm.ComboBoxEx1.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'client' ).AsString := addOrderForm.Edit2.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'telefon' ).AsString := addOrderForm.Edit3.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'email' ).AsString := addOrderForm.Edit4.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'detalii' ).AsString := addOrderForm.Edit5.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'livrare' ).AsString := addOrderForm.ComboBoxEx6.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'pret' ).AsString := addOrderForm.Edit7.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'user' ).AsString := addOrderForm.ComboBoxEx8.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'status' ).AsString := addOrderForm.ComboBoxEx9.Text ;
dbmodule.comenziQuery.Params.ParamByName( 'observatii' ).AsString := addOrderForm.Edit10.Text ;
dbmodule.comenziQuery.ExecSQL ;
end;
end;
end;
如果我在所有插入的表单上将Edit4 留空,但该订单的字段email 没有Null 值,则它显示为空 - 不为空,但也没有数据。
email 列在db 中默认设置为Null,所以这不是问题。
那里的值之间应该显示 2 个 NULL,但它只是空的。
有什么想法吗?
使用 Rad Studio 10 Seattle 和 dbExpress 组件
编辑
-
comenziQuery 是
TSQLQuery -
dbmodule 是包含数据库组件的
data module的名称 -
数据集是
TSimpleDataSet -
comenziConnection 是
TSQLConnection的名称
对于任何未来的读者,请务必阅读 cmets 的所有答案,那里有很棒的东西。
【问题讨论】: