Recent

Author Topic: Problem connecting to DB via ODBC in Windows 10  (Read 516 times)

Vodnik

  • Jr. Member
  • **
  • Posts: 98
Problem connecting to DB via ODBC in Windows 10
« on: September 09, 2019, 05:02:52 pm »
My application works fine on Win 7 and Win 2012 server, but on Win 10 reports an error: Could not connect with connection string "DSN=...  (see screenshot). Some time ago I have found a solution in internet - switch off Windows manifest in Project / Options / Compiler. But now it doesn't work anymore :(
I have no Win 10 PC, problem is reported by users.
Lazarus v1.8.4
Any ideas?
Users seems to have Russian interface in Win 10, that results with unreadable error message. My application is fully in English. How can I make error message readable?

wp

  • Hero Member
  • *****
  • Posts: 6235
Re: Problem connecting to DB via ODBC in Windows 10
« Reply #1 on: September 09, 2019, 06:17:53 pm »
Which kind of DB?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Vodnik

  • Jr. Member
  • **
  • Posts: 98
Re: Problem connecting to DB via ODBC in Windows 10
« Reply #2 on: September 09, 2019, 09:03:55 pm »
Informix

wp

  • Hero Member
  • *****
  • Posts: 6235
Re: Problem connecting to DB via ODBC in Windows 10
« Reply #3 on: September 10, 2019, 12:11:14 am »
Sorry, no idea about this one. I just want to note that the bitness of the ODBC driver must match the bitness of the application. IOW: when you compile a 32-bit application you need a 32-bit driver, for a 64-bit application you need a 64-bit driver. And I should also note that sometimes the 64-bit drivers do not work
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

af0815

  • Sr. Member
  • ****
  • Posts: 349
Re: Problem connecting to DB via ODBC in Windows 10
« Reply #4 on: September 10, 2019, 07:57:26 am »
This look like the dialog have not the possibility to handle the charset of the driver message.

Is it possible to catch the message as an exception and write it to a utf-8 file ?

Code: Pascal  [Select]
  1.    try
  2.        Connection.Connected:=true;
  3.         if not(GetConnectionUser.Connection.Connected) then begin
  4.           DebugLn('Cannot connect to DB');
  5.         end;
  6.     except
  7.       on E: Exception do begin
  8.         DebugLn( 'Connection not possible - Connection Exception: '+ E.Message);
  9.        // here you can write the exception to a file if you want
  10.       end;
  11.     end;
  12.  
« Last Edit: September 10, 2019, 08:01:25 am by af0815 »
regards
Andreas

Vodnik

  • Jr. Member
  • **
  • Posts: 98
Re: Problem connecting to DB via ODBC in Windows 10
« Reply #5 on: September 10, 2019, 12:32:59 pm »
@wp, application is 32 bit, ODBC driver is 32 bit, too.
Seems that discussion https://forum.lazarus.freepascal.org/index.php/topic,14203.msg74980.html#msg74980
may be relevant to my problem...

Vodnik

  • Jr. Member
  • **
  • Posts: 98
Re: Problem connecting to DB via ODBC in Windows 10
« Reply #6 on: September 12, 2019, 03:52:32 pm »
This was my stupid mistake... :-[
DatabaseName = "CRS" and Connected = True in TODBCConnection, this is comfortable at design time.
UserName and Password are empty, they are set in ODBC driver.
Application tries to connect to DSN "CRS" at start time, before user select another DSN in application.
This works when there is DSN with name "CRS" at user's PC and cause error when not.
So unchecking Connected (False) solved the problem.

Question still left is what to do to make error message readable on Russian Windows.