根据documentation对于 SQLDriverConnect,
Because of connection string and initialization file grammar, keywords and attribute values that contain the characters []{}(),;?*=!@ not enclosed with braces should be avoided.
和
A DSN or connection string value enclosed with braces ({}) containing any of the characters []{}(),;?*=!@ is passed intact to the driver.
使用连接字符串
DSN=%s;UID=%s;PWD={%s}
在 SQLServer 中工作 - 事实上,如果有某些特殊字符,那么不在 {} 中包含密码就会失败。但是,对 MS Access 使用相同的字符串会因“密码无效”而失败,并且在 {}
时有效。已移除。它也不适用于 Oracle。如果 {} 中包含的字符串原封不动地传递给服务器,那么它不应该工作吗?还是我错过了什么?
最佳答案
SQLDriverConnect's Access-specific page指出:
The PWD keyword should not include any of the special characters (see SQL_SPECIAL_CHARACTERS in SQLGetInfo Returned Values).
调用SQLGetInfo function在连接到 Access 并将 SQL_SPECIAL_CHARACTERS 作为 InfoType 参数传递时,应返回@Andrew Gibson 提到的禁止字符。
knowledge base article 的“更多信息”部分有一个不建议在 Access 应用程序中使用的特殊字符列表。
IBM 的 DB2 有一个同名的 SQLGetInfo function具有相同的参数列表并采用相同的 InfoType 常量来返回特殊字符,如下所示:
all characters except a...z, A...Z, 0...9, and underscore
关于oracle - 将密码包含在 {} 中时,SQLDriverConnect 有时会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17145013/