+ -
当前位置:首页 → 问答吧 → delphi 7 至少一个参数没有被指定值

delphi 7 至少一个参数没有被指定值

时间:2011-09-02

来源:互联网

程序功能:将EXCEL导入access 数据库表t_productproperty(t1) 中,并将表t_shippingCost(t2)中对应的值更新到表t1中
代码如下:
Delphi(Pascal) code

procedure TFinput_ZZ.btnSelectAndInputClick(Sender: TObject);
var sqlstr : string;
begin
//导入数据库
 sqlstr := 'insert into t_ProductProperty(Fyear,FPeriod,FFactory,FName,FWeight,FWireWeight) SELECT * FROM [EXCEL 8.0;DATABASE=D:\excel\成品属性表.XLS].[SHEET1$]';

 with datamd.adoproductProperty do
  begin
   close;
   sql.Clear;
   parameters.Clear;
   paramcheck := false;
   sql.Add(sqlstr);
   execsql;
   end;
//更新表t_productProperty中shipping字段
    with datamd.adoproductProperty do
     begin
      close;
      sql.Clear;

      sqlstr := 'update t_productProperty t1,t_shippingCost t2 set t1.fshipping = (t2.fshippingCost)*(t1.weight) where t1.fyear = t2.fyear and t1.fperiod = t2.fperiod and t1.factory = t2.factory ';
      sql.Add(sqlstr);
      execSQL;
       end;
showmessage('导入成功');

end;




错误:点击按钮后弹出异常:Project cost.exe raised exception class eolexception with message '至少一个参数没有被指定值 '………………

请问这是什么原因呢?
谢谢大家的关注 。

作者: lvlufeng   发布时间: 2011-09-02

你不能select * 啊,你得保证前后字段完全对应

作者: bdmh   发布时间: 2011-09-02

引用 1 楼 bdmh 的回复:
你不能select * 啊,你得保证前后字段完全对应


您好,谢谢您 的回答,可是前一段代码测试是成功的,能成功导入

加了下面一段后再运行就出错了:
Delphi(Pascal) code

//更新表t_productProperty中shipping字段
    with datamd.adoproductProperty do
     begin
      close;
      sql.Clear;

      sqlstr := 'update t_productProperty t1,t_shippingCost t2 set t1.fshipping = (t2.fshippingCost)*(t1.weight) where t1.fyear = t2.fyear and t1.fperiod = t2.fperiod and t1.factory = t2.factory ';
      sql.Add(sqlstr);
      execSQL;
       end;



搞不清原因

作者: lvlufeng   发布时间: 2011-09-02

你的SQL语句写错了。可能是这样的吧

SQL code
 
  update t_productProperty  set fshipping = (t2.fshippingCost)*(t1.weight) 
  from  t_productProperty t1,t_shippingCost t2
  where t1.fyear = t2.fyear and t1.fperiod = t2.fperiod and t1.factory = t2.factory

作者: moshao6   发布时间: 2011-09-02

引用 3 楼 moshao6 的回复:
你的SQL语句写错了。可能是这样的吧


SQL code


update t_productProperty set fshipping = (t2.fshippingCost)*(t1.weight)
from t_productProperty t1,t_shippingCost t2
where t1.fyear = t2.fyear and t1.f……

您好,谢谢您 的回答 改成这样之后确实那个错误没有了
Delphi(Pascal) code

//导入数据并更新单位运费
procedure TFinput_ZZ.btnSelectAndInputClick(Sender: TObject);
var sqlstr : string;
begin

 sqlstr := 'insert into t_ProductProperty(Fyear,FPeriod,FFactory,FName,FWeight,FWireWeight) SELECT * FROM [EXCEL 8.0;DATABASE=D:\excel\成品属性表.XLS].[SHEET1$]';

 with datamd.adoproductProperty do
  begin
   close;
   sql.Clear;
   parameters.Clear;
   paramcheck := false;
   sql.Add(sqlstr);
   execsql;
   end;

    with datamd.adoproductProperty do
     begin
      close;
      sql.Clear;

      sqlstr := 'update t_productProperty  set t1.fshipping = (t2.fshippingCost)*(t1.fweight) from  t_productProperty t1 ,t_shippingCost t2 where t1.fyear = t2.fyear and t1.fperiod = t2.fperiod and t1.factory = t2.factory ';
      sql.Add(sqlstr);
      execSQL;
       end;
showmessage('导入成功');

end;


但是它说:
语法错误(缺少操作符)在查询表达式Delphi(Pascal) code

 (t2.fshippingCost)*(t1.weight) 
  from  t_productProperty t1,
语法错误(缺少操作符)

作者: lvlufeng   发布时间: 2011-09-02

热门下载

更多