表结构如下:
CREATE TABLE [jinhua] (
[id] [float] NULL ,
[F2] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F3] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F4] [float] NULL ,
[F5] [float] NULL ,
[F6] [float] NULL ,
[F7] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F8] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F9] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F10] [float] NULL ,
[F11] [float] NULL ,
[F12] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F13] [float] NULL ,
[F14] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F15] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F16] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F17] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
[F18] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO
----------delphi这样写的---------------sqlstr:= '';
     if Button1.Caption ='添加' then  // insert
        begin
           sqlstr := sqlstr + 'insert into jinhua(F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13) values (';
           sqlstr := sqlstr + ':danwei,:jinli,:ff4,:ff5,:ff6,:ff7,:ff8,:ff9,:ff10,:ff11,:ff12,:ff13)';
        end
     else
        begin
          sqlstr := sqlstr + 'update jinhua set F2=:danwei,F3=:jinli,F4=:ff4,F5=:ff5,';
          sqlstr := sqlstr + 'F6=:ff6,F7=:ff7,F8=:ff8,F9=:ff9,';
          sqlstr := sqlstr + 'F10=:ff10,F11=:ff11,F12=:ff12,F13=:ff13 ';
          sqlstr := sqlstr + 'where id=:id';
        end;        tempQuery := TADOQuery.Create(nil);
        tempQuery.Close;
        tempQuery.SQL.Clear;
        tempQuery.SQL.Add(sqlstr);                      tempQuery.Parameters.ParamByName('danwei').value:= Edit3.Text;
                    tempQuery.Parameters.ParamByName('jinli').value:= Edit8.Text;
                    tempQuery.Parameters.ParamByName('ff4').value:= Edit10.Text;
                    tempQuery.Parameters.ParamByName('ff5').value:= Edit9.Text;
                    tempQuery.Parameters.ParamByName('ff6').value:= Edit2.Text;
                    tempQuery.Parameters.ParamByName('ff7').value:= Edit6.Text;
                    tempQuery.Parameters.ParamByName('ff8').value:= Edit4.Text;
                    tempQuery.Parameters.ParamByName('ff9').value:= Edit5.Text;
                    tempQuery.Parameters.ParamByName('ff10').value:= Edit13.Text;
                    tempQuery.Parameters.ParamByName('ff11').value:= Edit12.Text;
                    tempQuery.Parameters.ParamByName('ff12').value:= Edit11.Text;
                    tempQuery.Parameters.ParamByName('ff13').value:= Edit7.Text;
                 if  Button1.Caption <>'添加' then
                    tempQuery.Parameters.ParamByName('id').value:= Edit1.Text;        tempQuery.ExecSQL;
        tempQuery.Free;               showMessage('操作成功!')--------------------------------
danwei,jinli 这些参数都不认识,为什么? help

解决方案 »

  1.   

    'update jinhua set F2=:danwei,F3=:jinli,F4=:ff4,F5=:ff5,';
    ................ update jinhua set f2='''+danwei+'''.................
      

  2.   

    将SQL语句SHOW出来看看,认真检查检查。
      

  3.   

    showmessage(tempQuery.SQL.Text);看看有没有错
      

  4.   

    博客网络导航:http://www.haoup.com/default.htm
      

  5.   

    表面看好像没什么问题。
    用数据库的跟踪程序跟一下,看到底提交的是什么
    以前遇到到用带参数的SQL在MS SQL Server 2000上给参数赋中文字符,赋进去以后字符变掉了的情况
      

  6.   

    tempQuery := TADOQuery.Create(nil);
    //-----数据库连接在哪儿呢?
    tempquery.connection:=mainform.adoconnection1;
    //----------------------
            tempQuery.Close;
            tempQuery.SQL.Clear;
            tempQuery.SQL.Add(sqlstr);
      

  7.   

    我觉得也是,首先需要确定执行时候的SQL语句是否正确,可以ShowMessage确定一下按照错误提示看来是所有的参数都不存在吧,