We help IT Professionals succeed at work.

Kylix and Mysql 3,23

venks
venks asked
on
Can any one tell me the complete procdure of using kylix desktop with mysql 3.23 including what libraries to use and how to use?I have tried it but it does not seem to work
I am having redhat linux with 7.1 and mysql 3.23
Mysql is running fine in my net work
tahnks
venks
Comment
Watch Question

Commented:
listening...

(I'm fighting with the same problem right now.)

Author

Commented:
I have solved the rpoblem now.I just stopped using DBexpress and started using Zeos database components and is also free ware.It is working great.
I am not deleting this question so that more people can see this and benifit
venks
Commented:
Here goes my example:

// _libmysq.pas
unit _libmysq;

interface

type

  MYSQL_STATUS=(MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT);

  PUSED_MEM=^USED_MEM;

  USED_MEM=record
             next:PUSED_MEM;
             left,size: Cardinal;
           end;

  MEM_ROOT=record
             free,used:PUSED_MEM;
             min_malloc,block_size: Cardinal;
             error_handler: procedure;
           end;

  NET=record
         fd: word;
         fcntl: integer;
         buff,buff_end,write_pos: pchar;
         last_error: array[01..200] of char;
         last_errno,max_packet,timeout,pkt_nr: Cardinal;
         error,return_errno, compress: shortint;
      end;

  PMYSQL_FIELD=^MYSQL_FIELD;
  MYSQL_FIELD=record
                name,table,def: pchar;
                _type: byte;
                length,max_length,flags,decimals: Cardinal;
              end;
          
  PMYSQL=^MYSQL;
  MYSQL= record
           _net: NET;
           host,user,passwd,unix_socket,server_version,host_info,info,db: pchar;
           port,client_flag,server_capabilities,protocol_version,field_count: Cardinal;
           thread_id, affected_rows, insert_id, extra_info:longint;
           status: MYSQL_STATUS;
           fields: PMYSQL_FIELD;
           field_alloc: MEM_ROOT;
           free_me, reconnect: shortint;
         end;

 PMYSQL_ROW=^MYSQL_ROW;
 MYSQL_ROW= array[0..255] of pchar;

 PMYSQL_ROWS=^MYSQL_ROWS;
 MYSQL_ROWS=record
    next: PMYSQL_ROWS;
    data: PMYSQL_ROW;
  end;
                             

 PMYSQL_DATA= ^MYSQL_DATA;
 MYSQL_DATA= record
   rows, fields: Cardinal;
   data: PMYSQL_ROWS;
   alloc: MEM_ROOT;
 end;
                                         

 PMYSQL_RES=^MYSQL_RES;
 MYSQL_RES= record
     row_count: longint;
     field_count, current_field: Cardinal;
     fields: PMYSQL_FIELD;
     data: PMYSQL_DATA;
     data_cursor: PMYSQL_ROWS;
     field_alloc: MEM_ROOT;
     row: PMYSQL_ROW;
     current_row: PMYSQL_ROW;
     lengths: ^Cardinal;
     handle: ^MYSQL;
     eof: shortint;
  end;

function mysql_init ( _mysql: pmysql):pmysql;cdecl; external 'libmysqlclient.so';
function mysql_real_connect(_mysql: pmysql; const host, user, passwd, db:pchar;
 port:Cardinal; unix_socket:PChar;clientflag:Cardinal):pmysql;cdecl;
 external 'libmysqlclient.so';
procedure mysql_close( _mysql: pmysql); cdecl;
 external 'libmysqlclient.so';
function mysql_query ( _mysql: pmysql;  const query: pchar): integer; cdecl; external 'libmysqlclient.so';
function mysql_store_result (_mysql: pmysql): pmysql_res; cdecl; external 'libmysqlclient.so';
function mysql_fetch_row (result: pmysql_res): pmysql_row; cdecl; external 'libmysqlclient.so';
procedure mysql_free_result(result: pmysql_res); cdecl; external 'libmysqlclient.so';
function mysql_errno (_mysql: pmysql): integer;cdecl ; external 'libmysqlclient.so';
function mysql_error (_mysql: pmysql): pchar; cdecl; external 'libmysqlclient.so';

implementation

end.

// test.pas
program test;

uses SysUtils,
     _libmysq;

var
  dbcon: mysql;
  host, user, passwd, db, socket: string;
  port, flag: cardinal;
  Query: string;
  Presults: PMYSQL_RES;
  Results: MYSQL_RES;
  prow: PMYSQL_ROW;
  i: integer;
  aa: string;

begin
  MySQL_init(@dbcon);
  host:='159.148.116.4';
  user:='atis.l';
  passwd:='xexe, your pass';
  db:='Fignja';
  socket:='';
  port:=3306;
  flag:=0;
  MySQL_real_connect(@dbcon,PChar(host),PChar(user),PChar(passwd),PChar(db),port,PChar(socket),flag);
  Query:='SELECT * FROM Kakas;';
  if 0<>MySQL_query(@dbcon,PChar(Query)) then begin
   aa:=mysql_error(@dbcon);
   WriteLn('Error: '+aa);
   exit;
  end;
  Presults:=nil;
  PResults:=MySQL_Store_Result(@dbcon);
  Results:=PResults^;
//  WriteLn(IntToStr(MySQL_Field_Count(@dbcon)));
  for i:=1 to Results.row_count do begin
    prow:= mysql_fetch_row(PResults);
    WriteLn(prow^[0]+' | '+prow^[1]);
  end;
  mysql_free_result(PResults);
end.

Author

Commented:
I have awarded the points.But what about using ready made components like dbexpress or zeos which reduces the development time
venks

Explore More ContentExplore courses, solutions, and other research materials related to this topic.