我现在excel表中有itemno ,desc, ttr,mmf几个字段的数据;数据库除了Excel中的几个字段外,还有几个字段; 现在我要用Excel中的数据去更新数据库相关数据;!我该怎么办?  
   我的思路是这样的: 用excel中的itemno与数据库中的itemno相比较,如果itemno相同就用excel的数据去修改数据库中对应的数据;  在excel中逐条取数据;这样的话我怎么获得excel的记录条数呢?

解决方案 »

  1.   

    >>在excel中逐条取数据;这样的话我怎么获得excel的记录条数呢?ADO 聯接可以得到, 具體可參考<<delphi7 從入門到精通>>
      

  2.   

    你可以通过ADO来连接EXCEL,
    对数据集进行操作
      

  3.   

    var
      qry:tadoquery;
    beginqry :=TADOQuery.Create(nil);
    try
       qry.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\1.xls;Extended Properties=Excel 8.0';
     with qry do
       begin
         Close;
         sql.Clear;
         sql.Add('select * from [sheet1$]');
        open;
       
       end;
     finally
    qry.free;
    end;
    end;
      

  4.   

    请教各位一个问题;在delphi 中,我同时查询多个条件的记录该怎么处理,比如我要查询供求职位:为软件工程师,电工,车工 的所有记录我该怎么处理?
      

  5.   

    'Select * from [sheet1$] where 职位 like ''%软件工程师%'' OR 职位 like ''%电工%'' OR 职位 like ''%车工%'' '
      

  6.   

    晕倒
    用3个edit作为条件,如果为空就算没有
    实例如下procedure TForm1.Button1Click(Sender: TObject);
    var str:string;
    begin
      str:='where ';
      if edit1.Text <>'' then
        str := str + '职位 like ''%'+trim(edit1.Text)+'%'' OR ';
      if edit2.Text <>'' then
        str := str + '职位 like ''%'+trim(edit2.Text)+'%'' OR ';
      if edit3.Text <>'' then
        str := str + '职位 like ''%'+trim(edit3.Text)+'%'' OR ';
      if length(str)<7 then//防止一个条件也没有的
        str:='';
      if rightstr(str,3)='OR ' then
        str:=leftstr(str,length(str)-3);  str := 'Select * from [sheet1$] '+str;
      showmessage(str);end;
      

  7.   

    问题我自己解决了,代码给你们看看 SqlStr:='Select A.INVNUMBER from OEINVH AS A,OEINVD AS B where A.INVNUMBER=B.INVNUMBER ';
         for i:=0 to Memo2.Lines.Count-1 do
           begin
           if i=0 then
           SqlStr:=SqlStr+' and A.INVNUMBER='+Memo2.Lines.ValueFromIndex[i]
           else
           SqlStr:=SqlStr+' or A.INVNUMBER='+Memo2.Lines.ValueFromIndex[i];
           end;现在问题是我上面的代码想配对"'"引号总是不行;
        我这段代码不管有多少条件我都不怕;  大家帮忙看看引号问题好吗?
      

  8.   

    SqlStr:='Select A.INVNUMBER from OEINVH AS A,OEINVD AS B where A.INVNUMBER=B.INVNUMBER ';
         for i:=0 to Memo2.Lines.Count-1 do
           begin
           if i=0 then
             SqlStr:=SqlStr+' and A.INVNUMBER='''+Memo2.Lines.ValueFromIndex[i]+''' '
           else
             SqlStr:=SqlStr+' or A.INVNUMBER='''+Memo2.Lines.ValueFromIndex[i]''' ';
           end;