错误:3704关闭对象时不允许操作

时间:2018-08-07 10:00:37

标签: sql vbscript asp-classic xlsx adodb

我正在尝试使用ADODB连接打开Excel工作表,但是尽管工作表的名称正确,但是当我尝试执行查询时却遇到以下错误:

  

错误号:3704

     

错误描述:关闭对象后不允许操作

我已经遍历了在线提供的大多数答案,但是由于我已经阅读了答案中缺少的内容,因此我仍然可以找到答案。

这是我的代码:

Dim objConn

Set objConn = Server.CreateObject("ADODB.Connection")

Dim ext : ext = GetFileExt(filename)

If ext = "xlsx" Then
  With objConn
    .Provider = "Microsoft.ACE.OLEDB.12.0"
    .ConnectionString = _
      "Data Source=" & Server.MapPath("../import/" & filename) & ";" & _
      "Extended Properties=Excel 12.0;"
    .CursorLocation = adUseClient
    .Open
  End With
End If

Dim sql
sql = "SELECT * FROM [" & worksheet & "$]"
Dim objRs
Set objRs = objConn.Execute(sql)
response.write "err.number: " & Err.Number            '3704
response.write "err.Description: " & Err.Description  'Operation is not allowed when the object is closed

0 个答案:

没有答案