Hello, I just cannot get this error out of the way:
Operation is not allowed when the object is closed.
And here is my code:
The error points at this line: set rs = objConn.Execute(sql)
Operation is not allowed when the object is closed.
And here is my code:
Code:
ConnStr = "Driver={Microsoft Excel Driver (*.xls)};" & _
"DriverId=790;" & _
"Dbq="&Server.MapPath("/excel/Book1.xlsx") & _
"DefaultDir=c:\somepath"
On Error Resume Next
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.mode = 3 ' adModeReadWrite
objConn.Open ConnStr
if err.Number <> 0 then
TrapError Err.Description
Error.Clear
end if
on error goto 0
sql = "SELECT * FROM [Sheet1]"
set rs = objConn.Execute(sql)
if not rs.eof then
testField = rs.getRows()
end if
rs.close
set rs=nothing
objConn.close
set objConn = nothing
The error points at this line: set rs = objConn.Execute(sql)