Are there restricted characters in ADO varchars?

末鹿安然 提交于 2019-12-13 03:31:08

问题


We have a simple file browser on our intranet, built using ASP/vbscript. The files are read by the script and added to an ADO Recordset (not connected to a database), so we can sort the contents easily:

        Set oFolderContents = oFolder.Files
        Set rsf = Server.CreateObject("ADODB.Recordset")
        rsf.Fields.Append "name", adVarChar, 255
        rsf.Fields.Append "size", adInteger
        rsf.Fields.Append "date", adDate
        rsf.Fields.Append "type", adVarChar, 255
        rsf.Open

        For Each oFile In oFolderContents
            if not left(oFile.Name, 3) = "Dfs" then 'Filter DFS folders
                rsf.AddNew
                rsf.Fields("name").Value = oFile.Name
                rsf.Fields("size").Value = oFile.Size
                rsf.Fields("date").Value = oFile.DateCreated
                rsf.Fields("type").Value = oFile.Type
            end if
        Next

In one particular folder we are getting an error:

Microsoft Cursor Engine error '80040e21'
Multiple-step operation generated errors. Check each status value.

This points to the line

rsf.Fields("name").Value = oFile.Name

in the code above.

My initial thought this was caused by a long file name, but I checked the length of all the files in the directory - although some are quite long, all are under the 255 character limit set above (largest is 198 characters long).

The folder in question has nearly 2000 PDFs in it, and I do not have permissions to alter the contents, just read (it's a technical library). The files have a naming convention of "ID# - Paper Title". Some have special characters such as ', &, and ( or ) - could some of these be causing the issue? I don't recall having such a problem before. I tried searching Google for special characters in ADO, but couldn't find anything which seemed relevant.

Thanks :-)


回答1:


Have you tried using adVarWChar for the name column?



来源:https://stackoverflow.com/questions/536358/are-there-restricted-characters-in-ado-varchars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!