日期:2014-05-18  浏览次数:20603 次

database.ExecuteSQL(sSql);这句话有什么问题?
在用vc向excel导出数据的过程中

每次执行这句话都跳出
  CATCH_ALL(e)
  {
cout<<"no Excel driver"<<endl;
TRACE1("Excel没有安装驱动: %s",sDriver);
  }
但我test了,driver是存在的
不知道 database.ExecuteSQL(sSql);
有什么问题

有人知道吗?

------解决方案--------------------
SQL code
--导出excel处理
declare @s nvarchar(4000)
set @s='bcp "'+
+N'select top 100 percent '
+N' case c.colid when 1 then o.name else N'''' end as 表名,'
+N' c.colid as 序号,'
+N' c.name as 字段名,'
+N' t.name 数据类型,'
+N' c.prec as 长度,'
+N' p.value as 字段说明,'
+N' m.text as 默认值'
+N' from '+quotename(@dbname)+N'.dbo.sysobjects o'
+N' inner join '+quotename(@dbname)+N'.dbo.syscolumns c on o.id=c.id'
+N' inner join '+quotename(@dbname)+N'.dbo.systypes t on c.xusertype=t.xusertype'
+N' left join '+quotename(@dbname)+N'.dbo.sysproperties p on c.id=p.id and c.colid = p.smallid'
+N' left join '+quotename(@dbname)+N'.dbo.syscomments m on c.cdefault=m.id'
+N' where o.xtype in(N''U'') and o.status>=0'
+N' order by c.id,c.colid'
+N'" queryout "'+@fname
+N'" /P"" /w'
exec master..xp_cmdshell @s,no_output
go