Recent

Author Topic: ODBC Mysql  (Read 949 times)

syalyshev

  • New Member
  • *
  • Posts: 29
ODBC Mysql
« on: May 02, 2023, 01:39:10 pm »
Screen shot of Connector/ODBC attached.
The knob "Test" returns:
Quote
Connection successsful
Pascal (Lazarus) code is:
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.Connect_DB();
  2. begin
  3.  
  4.   if ODBCConnection.Connected Then ODBCConnection.Close;
  5.   ODBCConnection.DatabaseName:='odbc_Mysql';
  6.   ODBCConnection.UserName:='operator';
  7.   ODBCConnection.Password:= 'alfasatcom';
  8.   ODBCConnection.Params.Add('DATABASE=kizs');
  9.   ODBCConnection.Params.Add('AUTOCOMMIT=1');
  10.   try
  11.      ODBCConnection.Open;
  12.     edMess.Text:='Connection to Mysql database "kizs"=OK!'
  13.   except
  14.         on E: ESQLDatabaseError do
  15.         edMess.Text:=E.Message;
  16.   end;
  17.  
  18.   ODBCConnection.Transaction:=SQLTransaction;
  19.   SQLQuery.Active:=false;
  20.   SQLQuery.SQL.Clear;
  21.   SQLQuery.SQL.Text:='SET NAMES "binary"';
  22.   SQLQuery.Active:=false;
  23.   SQLQuery.SQL.Clear;
  24.   SQLQuery.SQL.Add('select * from report_xpol order by id DESC limit 100');
  25.   SQLQuery.Active:=true;
  26.  
  27.   SQLQuery.Refresh;
  28.   Confirm_Connection.Caption:='Connected to DataBase';
  29.  
  30. end;
When I run the program it gives:

Quote
Could not connect with connection string "DSN=odbc_Mysql;UID=operator;PWD=password;DATABASE=kizs;AUTOCOMMIT=1;". ODBC error details: LastReturnCode: SQL_ERROR; Record 1: SqlState: IM014; NativeError: 0; Message: [Microsoft]…………………..

What have I done wrong?
« Last Edit: May 02, 2023, 03:20:28 pm by syalyshev »

Zvoni

  • Hero Member
  • *****
  • Posts: 2961
Re: ODBC Mysql
« Reply #1 on: May 02, 2023, 01:42:09 pm »
and your question is what?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

syalyshev

  • New Member
  • *
  • Posts: 29
Re: ODBC Mysql
« Reply #2 on: May 02, 2023, 01:58:50 pm »
Sorry! I corrected my message! Please see above!

marsupilami79

  • New Member
  • *
  • Posts: 38
Re: ODBC Mysql
« Reply #3 on: May 02, 2023, 03:37:10 pm »
Hello syalyshev,

Quote
SqlState: IM014; NativeError: 0; Message: [Microsoft]…………………..
The Message part would have been the interesting part ;)

But according to the SQL state IM014 and this post on StackOverflow you might be trying to use a 32 bits ODBC driver with a 64 bits application or vice versa. So you could try to change the Architecture of your program from 32 to 64 bits or vice versa. Or you could use a different ODBC driver.

With best regards,

Jan
Zeos developer

syalyshev

  • New Member
  • *
  • Posts: 29
Re: ODBC Mysql
« Reply #4 on: May 04, 2023, 07:31:54 am »
Dear marsupilami79, thanks a lot! I have done what you advised and it worked fine!
My best regards!

 

TinyPortal © 2005-2018