出错信息:Missing Connection or ConnectionString代码:
adoquery1.Close;
adoquery1.SQL.Clear;
batchdatafile:='c:\lw.xls';
sql:='select *  FROM OpenDataSource(''Microsoft.Jet.OLEDB.4.0'',''Data Source='''+batchdatafile+''';User ID=;Password=;Extended Properties="Excel 8.0;HDR=Yes;";Persist Security Info=False'')...[PRDT$]'  ;
adoquery1.Parameters.Clear;
adoquery1.ParamCheck := false;
adoquery1.SQL.Text := Sql;
adoquery1.Execsql;

解决方案 »

  1.   

    用一个adoconnection,adoconnection的连接串写''Microsoft.Jet.OLEDB.4.0'',''Data Source='''+batchdatafile+''';User ID=;Password=;Extended Properties="Excel 8.0;HDR=Yes;";Persist Security Info=False'',再用一个adoquery
      

  2.   

    没有将 adoquery1的connection属性设置:adoconnection1或用 qiujsh(四大皆空) (
      

  3.   

    connection没指,它用什么来解析你的SQL串?
    with ADOquery1 do
    begin
      Close;
      ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Persist Security Info=false;Data Source=你的excel文件';
      CommandText := 'SELECT * from [Sheet1$]';
      Open;
    end;