?
Solved

Delphi/Kylix with MySql

Posted on 2001-09-08
5
Medium Priority
?
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 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