Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi/Kylix with MySql

Posted on 2001-09-08
5
Medium Priority
?
605 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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