Error applying to attribute with hifen in LDAP name in Windows 8

Maurício Machado
Maurício Machado used Ask the Experts™
on
There is a VB6 application that uses ADODB to connect to LDAP and do a lot of operations, there is an LDAP Attribute (field) called "co-unit" and when the application runs specifically on Windows 8 (it has been tested on other OSs and works 100%) generates an "Unspecified error (-2147467259)" error and after analyzing the source code it was discovered that the problem is that when trying to run the Querye it does not accept any field that contains in its name the hyphen, for example co-unit , no-drive, dt-creation, etc ...

I have already searched in numerous forums including MVPs and other professionals but I have not been able to find any solution, because it seems that this problem should never have occurred.

I would like to know if there is anyone who can help me and give a light to solve this problem, I have tried everything, changed components, tried to get the Attribute through ADSPath among other ways and none gave result giving the same error.

You are my last attempt to help.

I'm waiting for some help from someone.

Excerpt from code that generates error:



sqlStmt = "SELECT uid, co-unit, cn" & _
    "FROM 'LDAP: //" & m_LDAPServer & ":" & m_LDAPPort & "/ o =" & m_Org & "/ ou =" & m_OrgPeople &
    "WHERE uid = '" & m_User & "'" & "and objectClass = '*'"
   
    'executes the data string ...
    Err.Clear
    Set rs = con.Execute (sqlStmt) 'IN THIS POINT IT GENERATES ERROR, BECAUSE IT DOES NOT ROLL THE STRING, ONLY IF I REMOVE THE FIELD co-unit BUT I NEED THIS FIELD FOR THE CONTINUITY OF THE OPERATION THAT THE SYSTEM DOES.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2018

Commented:
Try \-

Will check my old code, had this issue years ago
Software Developer
Commented:
Can you wrap the field name in square brackets?

sqlStmt = "SELECT uid, [co-unit], cn" & _
    "FROM 'LDAP: //" & m_LDAPServer & ":" & m_LDAPPort & "/ o =" & m_Org & "/ ou =" & m_OrgPeople &
    "WHERE uid = '" & m_User & "'" & "and objectClass = '*'"

Open in new window

Maurício MachadoEspecialista de Tecnologia

Author

Commented:
Thank you very much, your response helped me a lot in solving the problem.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial