Solved

Delphi/Kylix with MySql

Posted on 2001-09-08
5
596 Views
Last Modified: 2008-03-10
Can any one send me sample code/tutorial/components for using delphi/kylix and MySql
thanks
venks
0
Comment
Question by:venks
5 Comments
 
LVL 1

Expert Comment

by:saulite
ID: 6467069
with Delphi i have tried, tru ODBC, you need to download ODBC driver for MySQL. then use standard ODBC components.

I could give you real working example after few days (i dont have delphi right now, but the example that worked i have left at my friend's home PC :))

maybe after some 12h.
0
 
LVL 17

Expert Comment

by:inthe
ID: 6467327
hi,
you can use odbc as above but i prefer to use directly to mysql db using one of the mysql units/comps as sometimes end users may not have the odbc drivers installed etc..
this is one of the best component ones and works on all versions of windows.

http://productivity.org/projects/mysql/

also you can get the freeware source code for winmysql
(it was wrote in delphi using the units im mentioning above)it is a front-end / db-manager thing,one of the better ones for mysql,and with the source you can modify it to suit..
http://www.winmysql.com/page4.html

i also have a couple of demos of other mysql units etc if you want them let me know as i dont know where i got them though the above stuff should cover it all anyways.
Regards
Barry
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6469364
For Delphi, I find native access to mySQL is much faster... http://www.zeoslib.org

It's free :)
0
 
LVL 1

Accepted Solution

by:
saulite earned 100 total points
ID: 6481198
OK. here would be my example.
It executes query, and prints space seperated values into the memo.
Needed lybraries: MyOLEDB, MyODBC, can be found at www.mysql.com

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ADODB, Db;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ADOConnection1: TADOConnection;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
 ADOConnection1.ConnectionString:='DSN=UzeruDB';
// use 'ODBC Data Sources' in Control panel, to create a System DSN.'  
// you should set Driver('MySQL'), DSN Name (Used here), hostname ('localhost', or server IP), Database Name ('MYSQL').  
 Memo1.Align:=alBottom;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ADOConnection1.Open; // only if you need to ask user for username/pass
end;

procedure TForm1.Button2Click(Sender: TObject);
var RecSet: _Recordset;
    S: string;
    i: integer;
    j: integer;
begin
  RecSet:=ADOConnection1.Execute(Edit1.Text);
  S:=' | ';
  for i:=0 to RecSet.Fields.Count-1 do begin
    S:=S+RecSet.Fields[i].Name+' | ';
  end;
  Memo1.Lines.Add(S);
  Memo1.Lines.Add(''); //empty line
  for j:=0 to RecSet.RecordCount-1 do begin
    S:=' | ';
    for i:=0 to RecSet.Fields.Count-1 do begin
      S:=S+RecSet.Fields[i].Value+' | ';
    end;
    Memo1.Lines.Add(S);
    Memo1.Lines.Add('');
    RecSet.MoveNext;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  ADOConnection1.Close;
end;

end.
0
 
LVL 1

Author Comment

by:venks
ID: 6499286
thanks
venks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now