Sometimes SQLDriverConnect is interrupted when a password is included in {}

According to the documentation for SQLDriverConnect,

Due to the grammar of the connection and initialization file, keywords and attribute values ​​that contain the characters [] {} () ,; * * =! @ not included with braces.

and

A DSN or connection string value enclosed with braces ({}) containing any of the characters [] {} () ,; * * =! @, passed inward to the driver.

Using the connection string DSN=%s;UID=%s;PWD={%s} works in SQLServer - infact if there are certain special characters, and not closing the password in {} fails. However, the use of the same line for MS Access is not performed with an "incorrect password" and works when deleting {} . It also does not work with Oracle.

If a string enclosed in {} is passed to the server intact, should it not work? Or am I missing something?

+4
source share
1 answer

The SQLDriverConnect Access page indicates that:

The PWD keyword must not contain any special characters (see SQL_SPECIAL_CHARACTERS in the returned SQLGetInfo values).

Calling the SQLGetInfo function when connecting to Access and passing SQL_SPECIAL_CHARACTERS, because the InfoType argument should return forbidden @Andrew Gibson characters.

The "More Information" section in the Knowledge Base article contains a list of special characters that are not recommended for use in the Access application.

IBM DB2 has the identical SQLGetInfo function with the same parameter list and accepts the same InfoType constant to return special characters listed there as:

all characters except a ... z, A ... Z, 0 ... 9, and underscore

+1
source

Source: https://habr.com/ru/post/1486583/


All Articles