I'm trying to read data from an Excel spreadsheet (from a VBScript/ASP application), which has a header row.
The following code works fine, even for fields whose name includes spaces... except, there are fields that include a period which dont seem to work. The bolded line gives me the following error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
The field is spelled correctly. I also tried sCLID = rs("[Account No.]"), but get the same error.
Also, when I include this field in a WHERE statement, as in:
rs.Open "SELECT * FROM [Sheet1$] WHERE [Account No.] = '1'", Conn
I get:
Microsoft JET Database Engine error '80004005'
'' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.
Is there a way I can reference this field?
The following code works fine, even for fields whose name includes spaces... except, there are fields that include a period which dont seem to work. The bolded line gives me the following error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
Code:
Dim Conn, rs
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("/") & "\..\data\CustomerList.xls" & _
";Persist Security Info=False;Extended Properties='Excel 8.0'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM [Sheet1$] WHERE [Account No.] = '1'", Conn
Dim sAddress, sCLID
If rs.EOF Then
sAddress = "No Address"
Else
sAddress = rs("Bill To 1") & "<BR>" & rs("Bill To 2")
[b][COLOR=red]sCLID = rs("Account No.")[/color][/b]
End If
rs.Close
Conn.Close
The field is spelled correctly. I also tried sCLID = rs("[Account No.]"), but get the same error.
Also, when I include this field in a WHERE statement, as in:
rs.Open "SELECT * FROM [Sheet1$] WHERE [Account No.] = '1'", Conn
I get:
Microsoft JET Database Engine error '80004005'
'' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.
Is there a way I can reference this field?