积极答复者
win7中SQL语句

问题
答案
全部回复
-
不是操作系统层面的兼容性问题,是具体SQL Server上的。请问你用的是什么版本的SQL Server? 你有没有在Win7上安装Office Excel,是具体什么版本?
我测试了SQL Server 2008 和 2008 R2 两个版本去导入一个Excel 97-2003格式的xls文件,在Windows XP, 7 和 2008 Server R2下, 这个SQL都是可以工作的。
所以我觉得 “不可识别数据库类型”是不是和你选择的ADO连接有关, (顺便提一句,我测试用的 Microsoft Excel 连接Data Source), 你可以把你的 ADO 的具体配置贴出来,我们看下;还有,你要确保在你的Windows 7中,ADO连接器可以访问Excel类型的文件的。
对了,还有要提示一下的,Windows 7会用UAC保护C盘,默认情况下必须是 run as administrator 的进程才可以访问,所以你要尝试把你的SQL Server “Run as Administrator”, 或者把你的e.xls放到其它分区再试试。
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
首先谢谢版主。机器sql server 2000,sp3补丁。office2003,office2007均试过。
sql server直接导入没有问题。编写代码用ADO连接的不行。
可能象您说的是ADO连接问题。ADO和win7不兼容性吗?ADO在win7下可以连接access,excel,sql server等。
但目前遇到就是excel出问题了。并且以管理员身份运行的程序。连接excel是成功的。因为已经读出excel中的sheet页签,就是
使用这种方式读内容时“select * from [sheet1$]”,出问题了。报“不可识别的数据库格式”。XP是可以的。
目前Microsoft Data Access Components (MDAC) 2.8驱动已经装了。依然问题存在。
-
煮一下大小写,用[Sheet1$]。
还有,确保你安装的Office 是32位,使用32位的导入功能。
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
你好,
有个建议, 你可以用ADO开发一个例子去用 select * from [sheet1$] 读取下你的xls文件。我尝试了许多情况,都没有发现这个问题。我把它移到SQL Server那边看看有没有进一步信息吧
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
因为操作系统只是提供一系列API可以让各种应用程序能正常地运行工作,你的问题是围绕SQL执行的。操作系统本身是不带SQL执行能力的,这个问题关系到SQL Server 2000中的ADO在导入时的问题,我尝试重现,在Windows 7是好的,我这边测试了各版本的ADO,都可以解析[Sheet1$]。
你尝试过下面的这个了吗:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=C06B8369-60DD-4B64-A44B-84B371EDE16D
还有:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=78CAC895-EFC2-4F8E-A9E0-3A1AFBD5922E
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
赞! 原来如此。是不是你忘了在 Extended Properties="Excel 8.0; HDR=NO;IMEX=1;" 外面再加一层引号。
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.