更新Excel工作表(经典ASP / VBScript中) [英] Update Excel Sheet (in Classic ASP/Vbscript)
本文介绍了更新Excel工作表(经典ASP / VBScript中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图寻找一个code,将更新经典-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. "
感谢您这么多...
推荐答案
您的连接字符串是不正确的。
Your connection string is not right.
您有:
Provider=Microsoft.Jet.OLEDB.4.0 Data Source="
& Server.MapPath("TEST.xls") & "Extended Properties='Excel 8.0;HDR=No'"
您在4.0后缺少一个分号之前扩展
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屋!
查看全文