Solved

Delphi/Kylix with MySql

Posted on 2001-09-08
5
602 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 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