更新 Excel 工作表(在经典 ASP/Vbscript 中) [英] Update Excel Sheet (in Classic ASP/Vbscript)
本文介绍了更新 Excel 工作表(在经典 ASP/Vbscript 中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在 Classic-ASP 中搜索可更新 Excel (XLS) 文件的代码,但无法正常工作.
I tried to search for a code that would update a Excel (XLS) file in Classic-ASP but I cannot get it to work.
这是我所拥有的:
<!--#include file="../adovbs.inc"-->
<%
' Open and Update and then Close The XLS File
Dim objConn
set objConn = Server.CreateObject("ADODB.Connection")
Dim FLConnect
Dim strSQLexcel
' Create the connection string.
FLConnect = "Provider=Microsoft.Jet.OLEDB.4.0 Data Source=" & Server.MapPath("TEST.xls") & "Extended Properties='Excel 8.0;HDR=No'"
' Create the SQL statement.
strSQLexcel= "UPDATE [Sheet1$A1:A1] SET F1='TestValue1'"
set objConn = Server.CreateObject("ADODB.Recordset")
'Set objConn = New ADODB.Connection
' Create and open the Connection object.
objConn.Open FLConnect
' Execute the insert statement.
objConn.Execute strSQLexcel
' Close and destroy the Connection object.
objConn.Close
%>
但我一直收到错误消息:连接不能用于执行此操作.在此上下文中它已关闭或无效."
But I keep getting an error saying: " The connection cannot be used to perform this operation. It is either closed or invalid in this context. "
非常感谢...
推荐答案
你的连接字符串不对.
你有:
Provider=Microsoft.Jet.OLEDB.4.0 Data Source="
& Server.MapPath("TEST.xls") & "Extended Properties='Excel 8.0;HDR=No'"
您在 4.0 之后和 Extended 之前缺少一个分号
You are missing a semi-colon after 4.0 and before Extended
Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath("TEST.xls") & ";Extended Properties='Excel 8.0;HDR=No'"
请参阅 http://connectionstrings.com
这篇关于更新 Excel 工作表(在经典 ASP/Vbscript 中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文