直接访问服务器,用sql语句if object_id ('gongdan') is not null drop table gongdanselect * into gongdan from OPENROWSET('MICROSOFT.JET.OLEDB.4.0' ,'Excel 5.0;HDR=YES;DATABASE=c: book1.xls',[sheet1$]) 报错消息 7314,级别 16,状态 1,第 4 行 链接服务器 "(null)" 的 OLE DB 访问接口 "MICROSOFT.JET.OLEDB.4.0" 不包含表 "sheet1$"。该表不存在,或者当前用户没有访问该表的权限。
换一个语句 if object_id ('gongdan') is not null drop table gongdanSELECT * into newtable FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$] 这也不行
发错了 if object_id ('gongdan') is not null drop table gongdanSELECT * into gongdan FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
你确定你的是 "sheet1$" 不是 "Sheet1$"?
if object_id ('gongdan') is not null drop table gongdan
SELECT * into gongdan FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]这个在local下通过,在远程sqlserver2008 下报错,疯了,是不是要在服务器端 的c盘 复制一个book1.xls过去?
没自己写字符串,直接用adoconnection里面设置的 build建立的,测试链接成功
肯定要自己写一串
var
pstr:string;
path:string; --路径
pstr:='Provider=MSDASQL.1;Persist Security Info=False;Data Source=Excel Files;Initial Catalog='+path;
--然后
adoquery1.connectionstring:=pstr
drop table gongdanselect * into gongdan from
OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 5.0;HDR=YES;DATABASE=c: book1.xls',[sheet1$])
报错消息 7314,级别 16,状态 1,第 4 行
链接服务器 "(null)" 的 OLE DB 访问接口 "MICROSOFT.JET.OLEDB.4.0" 不包含表 "sheet1$"。该表不存在,或者当前用户没有访问该表的权限。
if object_id ('gongdan') is not null
drop table gongdanSELECT * into newtable
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
这也不行
if object_id ('gongdan') is not null
drop table gongdanSELECT * into gongdan
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
不是 "Sheet1$"?
drop table gongdan
SELECT * into gongdan
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\book1.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]这个在local下通过,在远程sqlserver2008 下报错,疯了,是不是要在服务器端 的c盘 复制一个book1.xls过去?
跟你说了OpenDataSource只能用于本地,你的c:\book1.xls只是本地的文件,服务器上没有。这样不行。听不懂啊?
跟你说了OpenDataSource只能用于本地,你的c:\book1.xls只是本地的文件,服务器上没有。这样不行。听不懂啊?那用什么方法呢?