提示错误是:无法启动应用程序,工作文件信息丢失,或被其它用户以独占方式打开,而且一点就提示输入用户名和密码,请高手看看!
if self.OpenDialog1.Execute then
with TAdoConnection.Create(self) do
try
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\a.xls;User ID=sa;Password=sa;Extended Properties="Excel 8.0;HDR=Yes;";Persist Security Info=False '; Open;
Execute('select * into dddd from [excel 8.0;data source=book1.xls].aaaa');
Close;
finally
free;
end;
if self.OpenDialog1.Execute then
with TAdoConnection.Create(self) do
try
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\a.xls;User ID=sa;Password=sa;Extended Properties="Excel 8.0;HDR=Yes;";Persist Security Info=False '; Open;
Execute('select * into dddd from [excel 8.0;data source=book1.xls].aaaa');
Close;
finally
free;
end;
解决方案 »
- 控件制作工具
- 这个十六制作代码如何还原成图片?
- 如何自退出刚启动的程序???
- Form销毁自己的问题
- 问一下windows更换主题时会发生些什么事情?UP有分。
- ListBox1click(self)?在线等
- 类型转换问题
- 程序运行时为何总要输入用户名和密码?请大家赐教
- 初学者提问
- 在IE上显示“LOGIN FAILED FOR USER 'YOUOU'”为何?
- [申请贴][hellolongbin 一个人]申请【语言基础/算法/系统设计】版版主,希望大家多多捧场!
- 工资软件中,我用的是EhGrid直接打印工资表,现在客户需要求合计,请问如何实现?各位老师帮帮忙,客户催的急,分不够再加,小弟在此拜谢
var
str,sqlstr,connstr,sheetName,filename:string;
begin
FileName :='d:\d.xls' ; //文件名
SheetName :='sheet1' ; //表名
ADOQuery1.Close ;
ADOQuery1.SQL.Clear ;
ConnStr :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + FileName + ';Extended Properties=Excel 8.0;Persist Security Info=False';
ADOQuery1.ConnectionString :=ConnStr ;
SqlStr :='Select * from ' +'[' +SheetName + '$'+']';
ADOQuery1.SQL.Add(SqlStr) ;
ADOQuery1.Prepared ;
ADOQuery1.Open ;
end;
end.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jet OLEDB:Database Password=sa
SheetName :='EXcel表名'; //打開的表名
var
myexcel:variant;
workbook:olevariant;
worksheet:olevariant;
i,j,k:integer;
begin
try
myexcel:=createoleobject('excel.application');
myexcel.application.workbooks.add;
myexcel.caption:='将数据导入到EXCEL表中';
myexcel.application.visible:=true;
workbook:=myexcel.application.workbooks[1];
worksheet:=workbook.worksheets.item[1];
except
showmessage('EXCEL不存在!');
end;
i:=0;
table1.first;
//加表头
for k:=0 to table1.FieldCount-1 do
worksheet.cells[1,1+k]:=table1.fields[k].DisplayName; //加数据
while not table1.eof do
begin
inc(i);
for j:=0 to table1.fieldcount-2 do
worksheet.cells[i+1,j+1]:=table1.fields[j].asstring;
table1.next;
end;end;
SheetName :='sheet1' ;
ADOQuery1.Close ;
ADOQuery1.SQL.Clear ;
ConnStr :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + FileName + ';Extended Properties=Excel 8.0;Persist Security Info=False';
ADOQuery1.ConnectionString :=ConnStr ;
SqlStr :='Select * from ' +'[' +SheetName + '$'+']' ; ADOQuery1.SQL.Add(SqlStr) ;
ADOQuery1.Prepared ; ADOQuery1.Open ;
showmessage(SqlStr);