我之前找过一些资料,已经正确用ADOCONNECTION连接了EXCEL文档,可是用ADOQUERY却怎么也打开文档,请问ADOQUERY中SQL如何编写??
  将EXCEL导入还有别的方法,请高手提供源代码学习学习!!!

解决方案 »

  1.   

    select *  from [$sheet]
      

  2.   

    if OpenDialog1.Execute then
      begin
        address := OpenDialog1.FileName;
        strTemp := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' +
          address +
          ';Extended Properties=Excel 8.0;Persist Security Info=False';
        con_code.ConnectionString := strTemp;
        try
          con_code.Connected := false;
          con_code.Connected := True;
        except
          Application.MessageBox('连接EXCEL失败,请查看是否文件格式有误!',
            gstrTitl, MB_ICONERROR + MB_OK);
          con_code.Connected := false;
          Abort;
        end;
        con_code.GetTableNames(ComboBox1.Items);
        tablename := ComboBox1.Items.Strings[0];
        sqltext := 'select * from [' + tablename + ']';
    选出数据结果然后插入sql server不是很好的办法