用AOD導入excel時失敗?

kyqSimon 2003-06-28 05:06:00
我的連接字符串conn.ConnectionString 為:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\test.xls;Persist Security Info=False

為何提示"無法出現資料庫格式"?
...全文
36 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Alexs 2003-08-06
  • 打赏
  • 举报
回复
改成:
SELECT * FROM [Sheel1$]
或:
SELECT * FROM "Sheel1$"
frogshero 2003-08-06
  • 打赏
  • 举报
回复
晚了
kyqSimon 2003-07-10
  • 打赏
  • 举报
回复
是呀,現在可以連上了,在我在adoquery的sql中寫SELECT * FROM Sheel1$ ,他為何說我的語句有錯?請再賜教!
zjy6631 2003-06-28
  • 打赏
  • 举报
回复
此外,还要注意,ado访问excel 是独占式访问,所以一个excel文档一旦被打开,就不能再用Ado 打开了。在打开之前,应把所有使用该excel文件的应用程序关闭。
zjy6631 2003-06-28
  • 打赏
  • 举报
回复

Set the ConnectionString property.

The ConnectionString property tells ADO how to connect to the datasource. Click the ellipse to display the ConnectionString dialog. We are going to build the string ourselves so select Use Connection String and click the Build button to display the Data Link Properties dialog. The first choice to make is what data provider are we going to use to get the data. To access Excel we use the Microsoft Jet OLEDB 4.0 Provider, select it and click Next. The next piece is what are we going to connect to. In this case we want to access an Excel file. Use the Browse button and find an Excel file on your system or use Forecast.xls provided in the ADOExcel.zip file. Before we can test the connection we need to enter an Extended Property to the connection string. Click OK to go back the ConnectionString dialog and type 'Extended Properties=Excel 8.0;' without the quotes at the end of the connection string (remember, all ConnectionString entries must be separated by semi-colons. This tells ADO that we need Excel support and use the type library associated with Excel 8.0. Go ahead and click Build again and then Test the connection. If you get Test Connection Succeeded, you did everything right. Close the ConnectionString dialog. The last property to set is the CommandText property.

注意:你必须在连接字符串中手动加入:Extended Properties=Excel 8.0;
这样才可以连接。
例:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\WUTemp\ADOExcel\Forecast.xls;Extended Properties=Excel 8.0;Persist Security Info=False
又如

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Program Files\Borland\Delphi5\Projects\ADOExcel\Forecast.xls;Extended Properties=Excel 8.0;Persist Security Info=False

把你的连接字符串改成:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\test.xls;Extended Properties=Excel 8.0;Persist Security Info=False

就会一切OK!!!

fhuibo 2003-06-28
  • 打赏
  • 举报
回复
up
sanoul 2003-06-28
  • 打赏
  • 举报
回复
呵呵,不懂,我向来是倒出,根本没有做过倒入,呵呵,up

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧