Escaping a semicolon in Oracle Connection String

Hi,
I hope you can help me with my (hopefully) easy problem :)

I am using the following connectionstring to connect to the Database in VBA:

strCon2 = "Driver={Oracle in OraClient11g_home2};Dbq=MY_SERVICE_NAME;" & _
              "Uid=MY_USER; Pwd=MY_PASSWORD;"

Everything works fine. If the user, however, uses a password with a semicolon, the connection fails saying that the user/password is wrong. Is there any way I can change the connection string such that it also works with semicolons in the password? I tried using curly braces, but then I get the error message "Invalid string or buffer length".

Thank you for your help,
Stefan

4 answers

See knowledge base article "Formating rules for connection strings".

Bullet number three.

https://www.connectionstrings.com/formating-rules-for-connection-strings/

Does it solve your problem? Let us know!

Thanks for your answer!
Unfortunately that doesn't seem to solve my problem. I did the following:

strCon2 = "Driver={Oracle in OraClient11g_home2};Dbq=MY_SERVICE_NAME;" & _
"Uid=MY_USER; Pwd=" & Chr(34) & MY_PASSWORD & Chr(34) & ";"

and it again yielded the strange message "Invalid string or buffer length"... This error message is very weird. Could it be an 32bit/64bit issue?

I think you are interpreting the formating information wrong.

Did not test it myself but it should be like this:

strCon2 = "Driver={Oracle in OraClient11g_home2};Dbq=MY_SERVICE_NAME;" & _
"Uid=MY_USER; Pwd='" & MY_PASSWORD & "';"

Does it work with the above format?

Unfortunately, I again got the message with the Invalid string or buffer length - really strange