?? 45.txt
字號:
SQl 查詢語句:SELECT * FROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0 ', 'Data Source= "d:/Example.xls ";Extended Properties=Excel 8.0 ')...APC DC$
報錯:
Server: Msg 7314, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0 ' does not contain table 'APCDC$ '. The table either does not exist or the current user does not have permissions on that table.
OLE DB error trace [Non-interface error: OLE DB provider does not contain the table: ProviderName= 'Microsoft.Jet.OLEDB.4.0 ', TableName= 'APCDC$ '].
我用的是Excel2003,SQL2000
另外,SQL表如何連接Excel表查詢,他們有一個共同的字段
問題點數:20 回復次數:18 顯示所有回復顯示星級回復顯示樓主回復
lwl0606
寒泉
等 級:
發表于:2007-09-24 11:20:231樓 得分:0
SELECT * FROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0 ', 'Data Source= "d:/Example.xls ";Extended Properties=Excel 8.0 ')...[APC DC$]
加個括號試試
lwl0606
寒泉
等 級:
發表于:2007-09-24 11:22:582樓 得分:8
SELECT * FROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0 ', 'Data Source= "d:\Example.xls ";Extended Properties=Excel 8.0 ')...[APC DC$]
斜線畫反了
lwl0606
寒泉
等 級:
發表于:2007-09-24 11:24:473樓 得分:0
也可以用
SELECT *
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database=d:\Example.xls ',[APC DC$])
連接表
SELECT a.*,b.id as id1
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database=d:\Example.xls ',[APC DC$]) a inner join table1 on a.id=table1.id
raulvim
等 級:
發表于:2007-09-24 13:48:084樓 得分:0
寒泉兄弟,斜線改正之后用的Excel2000可以執行成功(家里的電腦).辦公室的Excel2003,SQL2000下仍然報錯:
Server: Msg 7314, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0 ' does not contain table 'APCDC$ '. The table either does not exist or the current user does not have permissions on that table.
OLE DB error trace [Non-interface error: OLE DB provider does not contain the table: ProviderName= 'Microsoft.Jet.OLEDB.4.0 ', TableName= 'APCDC$ '].
另外3表連接查詢仍然需要請教你
raulvim
等 級:
發表于:2007-09-24 13:50:295樓 得分:0
兩個SQL表和一個Excel表有共同字段
winjay84
綠綠的蛋撻
等 級:
發表于:2007-09-24 13:57:596樓 得分:0
3表連接查詢:
SELECT a.*,b.id as id1
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database=d:\Example.xls ',[APC DC$]) a
inner join table1 on a.id=table1.id -- 共同字段
inner join table2 on a.id=table2.id -- 共同字段
raulvim
等 級:
發表于:2007-09-24 13:58:157樓 得分:0
SELECT *
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database=d:\Example.xls ',[APCDC$])
同樣報錯:
Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0 ' reported an error. The provider did not give any information about the error.
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0 ' IDBInitialize::Initialize returned 0x80004005: The provider did not give any information about the error.].
PS:我把表名去掉了空格,即APCDC
wgzaaa
等 級:
發表于:2007-09-24 14:02:228樓 得分:0
導入時要把導入的excel關閉
raulvim
等 級:
發表于:2007-09-24 14:14:399樓 得分:0
導入時要把導入的excel關閉?
不是導入,是連接查詢
wgzaaa
等 級:
發表于:2007-09-24 14:16:4010樓 得分:0
查詢也要關閉
winjay84
綠綠的蛋撻
等 級:
發表于:2007-09-24 14:37:2611樓 得分:0
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0 '
, 'Data Source= "d:\Example.xls ";User ID=Admin;Password=;Extended properties=Excel 5.0 ')...[APCDC$]
issacp
舉杯笑看人生
等 級:
發表于:2007-09-24 15:05:4412樓 得分:10
回復人:raulvim() ( 二級(初級)) 信譽:100 2007-9-24 13:48:08 得分:0
寒泉兄弟,斜線改正之后用的Excel2000可以執行成功(家里的電腦).辦公室的Excel2003,SQL2000下仍然報錯:
Server: Msg 7314, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0 ' does not contain table 'APCDC$ '. The table either does not exist or the current user does not have permissions on that table.
OLE DB error trace [Non-interface error: OLE DB provider does not contain the table: ProviderName= 'Microsoft.Jet.OLEDB.4.0 ', TableName= 'APCDC$ '].
另外3表連接查詢仍然需要請教你
===========================================================
Data Source= "d:\Example.xls "原因是由於這一句中的D盤是指服務器的D盤,而不是你當前電腦的D盤
raulvim
等 級:
發表于:2007-09-24 16:58:4013樓 得分:0
樓上說的對。但是3個表的連接查詢該如何做呢
raulvim
等 級:
發表于:2007-09-24 17:31:2014樓 得分:0
SELECT a.*,b.id as id1
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database=d:\Example.xls ',[APC DC$]) a
inner join table1 on a.id=table1.id -- 共同字段
inner join table2 on a.id=table2.id -- 共同字段
報錯:
Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'b ' does not match with a table name or alias name used in the query.
raulvim
等 級:
發表于:2007-09-24 17:37:1315樓 得分:0
SELECT a.*,b.id as id1,c.num
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database=d:\Example.xls ',[APC DC$]) a
inner join table1 b on a.id=b.id -- 共同字段
inner join table2 c on a.id=c.id -- 共同字段
這樣測試就通過了。謝謝!
brother2605
幽靈
等 級:
發表于:2007-09-24 17:40:5416樓 得分:2
SQl 查詢語句:SELECT * FROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0 ', 'Data Source= "d:/Example.xls ";Extended Properties=Excel 8.0 ')...APC DC$
------------------------------------------------------------
用OPENDATASOURCE 要加上用戶名和密碼,User ID=Admin;Password=;上面的錯誤里面已經告訴你了。
OPENDATASOURCE( '驅動名稱 ', '連接字符串 '),以你上面的為例:
SELECT * FROM OPENDATASOURCE( 'Microsoft.Jet.OLEDB.4.0 ', 'Data Source= "d:\Example.xls ";User ID=Admin;Password=;Extended Properties=Excel 8.0 ')...APC DC$
使用OPENROWSET則不需要
SELECT * FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0 ', 'Excel 8.0;Database= "d:\Example.xls ',[APC DC$])
raulvim
等 級:
發表于:2007-09-24 17:54:3917樓 得分:0
樓上是寒泉兄弟?怎么這么多馬甲
raulvim
等 級:
發表于:2007-09-24 17:56:4718樓 得分:0
Xlapp as Application
導入時要把導入的excel關閉?
查詢后如何關閉 Excel?
Xlapp.quit
Set Xlapp=nothing
?
*******************************************************************************************************
怎樣用DELPHI+SQL把查詢到記錄導成EXECL樓主kuangyulai(不務正業)2004-06-15 12:58:42 在 Delphi / 數據庫相關 提問
怎樣用DELPHI+SQL把查詢到記錄導成EXECL???
問題點數:0、回復次數:17
Top
1 樓kuangyulai(不務正業)回復于 2004-06-21 09:56:29 得分 0 怎么沒人回答我呀,我是新手幫幫忙吧!
給我一個簡單易懂的列子吧,謝謝了!!!
Top
2 樓kuangyulai(不務正業)回復于 2004-06-22 09:47:59 得分 0 怎么沒人回答我呀,我是新手幫幫忙吧!
給我一個簡單易懂的列子吧,謝謝了!!!
Top
3 樓qingfengman(清風飄逸)回復于 2004-06-22 10:17:54 得分 0 procedure TMainForm.CustomItem7Click(Sender: TObject);
Var
I :Integer;
ExcelApp,WorkBook :Variant;
d_Progress :Double;
begin
//數據寫入Excel
Screen.Cursor := crHourGlass;
ProgressBar1.Position := 0;
ProgressBar1.Min := 0;
ProgressBar1.Max := 100;
with ADOQuery1 do
begin
Close;
SQL.Text := 'Select * from mrm1000';
Open;
if RecordCount=0 then
begin
ProgressBar1.Position := 100;
messagedlg(#13 + 'No record.',mtinformation,[mbok],0);
Screen.Cursor := crDefault;
Exit;
end
else
begin
ExcelApp:=CreateOleObject('Excel.Application');
WorkBook:=ExcelApp.WorkBooks.add;
ExcelApp.ActiveSheet.PageSetup.Orientation := xlLandscape; //
ExcelApp.ActiveSheet.PageSetup.LeftMargin := 0.4;
ExcelApp.ActiveSheet.PageSetup.RightMargin := 0.4;//設置頁邊距
ExcelApp.Caption:='Employee';
ExcelApp.ActiveSheet.Columns[1].ColumnWidth:=10;
ExcelApp.ActiveSheet.Columns[2].ColumnWidth:=10;
ExcelApp.ActiveSheet.Columns[3].ColumnWidth:=10;
ExcelApp.ActiveSheet.Columns[4].ColumnWidth:=10;
ExcelApp.ActiveSheet.Rows[1].Font.Name := 'Times New Roman';
ExcelApp.Cells[1,3] := 'Employee Report';
ProgressBar1.Position := 2;
//ExcelApp.range[ExcelApp.Cells[1,3], ExcelApp.Cells[1,3]].Borders[4].Weight := 2;
//下劃線修改為字體的下劃線
ExcelApp.ActiveSheet.Rows[1].Font.Bold := True;
ExcelApp.ActiveSheet.Rows[1].Font.UnderLine := True;
ExcelApp.ActiveSheet.Rows[3].Font.Name := 'Times New Roman';
ExcelApp.Cells[3,1] := 'created date : ' + FormatDateTime('YYYY-MM-DD',now);
ProgressBar1.Position := 5;
ExcelApp.ActiveSheet.Rows[5].Font.Name := 'Times New Roman';
ExcelApp.range[ExcelApp.Cells[5,1], ExcelApp.Cells[5,4]].Interior.Color := clAqua;
ExcelApp.Cells[5,1] := 'Employee Code';
ExcelApp.Cells[5,2] := 'Employee Name';
ExcelApp.Cells[5,3] := 'Option Pwd';
ExcelApp.Cells[5,4] := 'Office Code';
I := 6;
d_Progress := 92/recordcount;
end;
while not eof do
begin
ProgressBar1.Position := round(ProgressBar1.Position + d_Progress);
ExcelApp.Cells[I,1] := FieldByName('user_code').AsString;
ExcelApp.Cells[I,2] := FieldByName('user_name').AsString;
ExcelApp.Cells[I,3] := FieldByName('user_pwd').AsString;
ExcelApp.Cells[I,4] := FieldByName('office_code').AsString;
Inc(I);
Next;
end;
end;
ProgressBar1.Position := 98;
ExcelApp.Cells[I,1] := 'Finished';
ProgressBar1.Position := 100;
Screen.Cursor := crDefault;
ExcelApp.visible:=true;
end;
Top
4 樓foxe(火狐)回復于 2004-06-22 11:51:16 得分 0 Good Sample!
Top
5 樓maxtool(≮From NingBoo≯)回復于 2004-06-23 14:25:04 得分 0 例子寫得很詳細!
Top
6 樓lrt119(啊杰)回復于 2004-06-23 18:47:46 得分 0 用QuantumGrid4吧 下載www.2ccc.com
用法:
引用 cxExportGrid4Link
導出Html
procedure ExportGrid1ToHTML(const AFileName: string; AGrid: TcxGrid; AExpand: Boolean = True; ASaveAll: Boolean = True);
導出excel
procedure ExportGrid1ToExcel(const AFileName: string; AGrid: TcxGrid; AExpand: Boolean = True; ASaveAll: Boolean = True; AUseNativeFormat: Boolean = False);
導出txt
procedure ExportGrid1ToText(const AFileName: string; AGrid: TcxGrid; AExpand: Boolean = True; ASaveAll: Boolean = True; const ASeparator: string = ''; const ABeginString: string = ''; const AEndString: string = '');
Top
7 樓yg123aa(愛吃肉的羊)回復于 2004-06-29 16:23:14 得分 0 我來補充一點,在導入時前面可加一個'號,才不受數據類型影響
Top
8 樓zgq19801123(小強)回復于 2004-06-29 16:30:04 得分 0 procedure speedtoexcel_user(Sinput:TwwDBGrid);
var
Ds_Master:Tdataset;
ExcelApplication1:TExcelApplication;
ExcelWorksheet1:TExcelWorksheet;
ExcelWorkbook1:TExcelWorkbook;
i,j:integer;
stringlist1:Tstringlist;
str1:string;
range1:string;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -