Database Path contains special characters like ! ( lazarus / 16-Databases ---------------------------------------------------------------------- shobits1 · 2017-04-19 19:37 I use TODBCConnection to connect/open MS-Access database (.mdb)... everything works great until I try to open Database inside directory having special characters in it's name. like 'D:\The Path to DB )\DB.mdb' After searching and searching, I can't find way to make this work. (the same DB can be opened by MS-Access 2010 with no problem) any help. ---------------------------------------------------------------------- HeavyUser · 2017-04-19 20:09 Quote from: shobits1 on April 19, 2017, 09:37:51 pmI use TODBCConnection to connect/open MS-Access database (.mdb)... everything works great until I try to open Database inside directory having special characters in it's name. like 'D:\The Path to DB )\DB.mdb' After searching and searching, I can't find way to make this work. (the same DB can be opened by MS-Access 2010 with no problem) any help. Access does not use odbc try to use ADO instead. ---------------------------------------------------------------------- shobits1 · 2017-04-19 20:56 How to use ADO in lazarus? Is it possible to use TDataSource, TSQLQuery? How much it defer from TODBCConnection, it term of code changes? I have minimal knowledge of Database programing, and I have already done so much in my current project (almost completed), and I don't want make big changes. Afaik, Zeos is the only component that uses ADO and it doesn't support (*.mdb) files - maybe I'm wrong - ---------------------------------------------------------------------- LacaK · 2017-04-20 05:38 There is no TADOConnection for FreePascal/Lazarus as ADO is Windows specific and not cross-platform. TODBCConnection should work. It will help if you can debug your application and catch connection string which is passed to SQLDriverConnect() or at least give error message which you get plus properties of your TODBCConnection object. ---------------------------------------------------------------------- shobits1 · 2017-04-20 16:44 I tried to debug TODBCConnection and catch the value of ConnectionString,, but for some reason the debugger won't let me -even thought, I rebuilt lazarus with debug profile-. anyway, this is the message I get: QuoteCould not connect with connection string "DRIVER={Microsoft Access Driver (*.mdb)};Dbq={D:\_Projects\SeesHelper\DATA\!SECG- ECO-2016.mdb};Uid=admin;Pwd=password;". ODBC error details: LastReturnCode: SQL_ERROR; Record 1: SqlState: HY000; NativeError: -1044; Message: [Microsoft][ODBC Microsoft Access Driver] Not a valid file name.; Record 2: SqlState: 01000; NativeError: 1; Message: [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x2154 Thread 0x230c DBC 0x677b4c4 Jet'.; and this is a cut down to how I open the DB: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmMain.OpenDataBase(ADBPath: string); begin  if not FileExists(ADBPath) then  begin    ShowMessage(msgFileNotFound);    Exit;  end   //  // Close all TSQLQuery  //  dbConnection.Close(True);  dbConnection.Driver := 'Microsoft Access Driver (*.mdb)';  dbConnection.Params.Add('Dbq=' + UTF8ToCP1256(ADBPath) );  //This gives the same error  //dbConnection.Params.Add('Dbq=' + ADBPath );  dbConnection.Params.Add('Uid=admin');  dbConnection.Params.Add('Pwd=password');  dbConnection.Open end; // No other parameters are changed in the ObjectInspector for dbConnection  if I rename the file from !SECG-ECO-2016.mdb to SECG-ECO-2016.mdb,, the Database opens successfully. [EDIT] BTW, changing the driver to Microsoft Access Driver (*.mdb, *.accdb) gives this error message: QuoteCould not connect with connection string "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};Dbq={D:\_Projects\SeesHelper\DATA\!SECG- ECO-2016.mdb};Uid=admin;Pwd=password;". ODBC error details: LastReturnCode: SQL_ERROR; Record 1: SqlState: HY000; NativeError: 63; Message: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xb0c Thread 0x2104 DBC 0x13817434                                                            Jet'.; Record 2: SqlState: HY000; NativeError: 63; Message: [Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0xb0c Thread 0x2104 DBC 0x13817434                                                            Jet'.; Record 3: SqlState: HY000; NativeError: -1044; Message: [Microsoft][ODBC Microsoft Access Driver] Not a valid file name.; ---------------------------------------------------------------------- miab3 · 2017-04-20 18:59 @shobits1, Try ZEOS and ADO. Here I wrote about it: http://zeoslib.sourceforge.net/viewtopic.php?f=40&t=67800#p86611 Michal ---------------------------------------------------------------------- shobits1 · 2017-04-20 20:58 Thank you, miab3 Yes it works with Zeos 7.2-beta but not the stable 7.1.4 (the one I was trying before); also I can use "Provider=Microsoft.Jet.OLEDB.4.0" which comes with WinXP and later. the only down side I see for now is that I have to rewrite all my TSQLQuery and use (I don't know) maybe TZQuery? TZSQLProcessor?! also there is the question of performance when using nested SQL anyway,, thank you again... I'm interested if there is way to continue using ODBC is my case (do not want to do big changes at least for now). ---------------------------------------------------------------------- miab3 · 2017-04-20 22:17 @shobits1, It also works with: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\Dane\ADDemo.mdb;Persist Security Info=False I advise to use ZEOS 7.2 svn 3986: https://sourceforge.net/p/zeoslib/code-0/HEAD/tree/branches/testing- 7.2/ Michal ---------------------------------------------------------------------- shobits1 · 2017-04-20 22:30 Quote from: miab3 on April 21, 2017, 12:17:35 amIt also works with: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\Dane\ADDemo.mdb;Persist Security Info=False Yes, I know... I was making statement, not asking; sorry for the confusion. Also, as side note for others; if DB has password, use Jet OLEDB:Database Password=mypassword; ---------------------------------------------------------------------- LacaK · 2017-04-25 05:48 Only tip: Try enclose path in double quotes: "":   dbConnection.Params.Add('Dbq="' + UTF8ToCP1256(ADBPath) + '"'); ---------------------------------------------------------------------- shobits1 · 2017-04-25 18:52 Quote from: LacaK on April 25, 2017, 07:48:38 amOnly tip: Try enclose path in double quotes: "":   dbConnection.Params.Add('Dbq="' + UTF8ToCP1256(ADBPath) + '"'); thank you,, but unfortunately it doesn't work.