How do I give a database path to ODBC Microsoft Access Driver with ampersand in it?
Asked Answered
C

1

0

My database path name has an ampersand in it. "...\mthly calcs & projections...".

Unfortunately, the path name cannot be changed. How do I deal with this case? Is there a way to specify the database path to the driver so it accepts the path with an ampersand? Maybe escaping it somehow or encoding it differently?

In the connection string if I use "&" doesn't work because ";" is interpreted as an option delimiter.

"jdbc:easysoft:mdb?DBQ=...\\mthly calcs & projections\\...\\Databases\\myDatabase.accdb;ExtendedAnsiSQL=1;READONLY=False;EXCLUSIVE=True"

I tested it by changing the path name by replacing the "&" with "and" and it works fine. Unfortunately in the production version the path names are fixed and I can't change them to remove the "&".

Caesium answered 26/12, 2022 at 2:46 Comment(4)
Asked this question in the comment of an older question but no response.Caesium
Try mthly calcs %26 projections or possibly mthly+calcs+%26+projectionsTundra
if you are connecting from Access try using the character code for &. "\\mthly calcs " & char(38) & "projections\\" if you are connecting from elsewhere try finding the equivalent for the vba function char()Keynesianism
@GordThompson Tried %26 for &. @Keynesianism Tried FromCharacterCode[38] also doesn't work. 38 is just the character code for & so it produces the same connection string.Caesium
L
0

Escaping the ampersand should work:

"jdbc:easysoft:mdb?DBQ=...\\mthly calcs \& projections\\...\\Databases\\myDatabase.accdb;ExtendedAnsiSQL=1;READONLY=False;EXCLUSIVE=True"
Loudhailer answered 26/12, 2022 at 13:6 Comment(2)
Escaping the & by \& also doesn't work.Caesium
Oh. How about doubling it: &&.Loudhailer

© 2022 - 2024 — McMap. All rights reserved.