Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to connect to a mySQL database Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-Sep-02
Category
Database Others
Language
Delphi 6.x
Views
137
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Senn Marco

How to connect to a mySQL database

Answer:

Perhaps you have already seen the uses clause. You may download mySQL.pas from 
www.fichtner.net/delphiwww.fichtner.net/delphi

1   uses mySQL;
2   
3   procedure Connect;
4   var
5     myServer: PMysql;
6     Tables: PMYSQL_RES;
7     TableRows: my_ulonglong;
8     Table: PMYSQL_ROW;
9   begin
10    myServer := mysql_init(nil);
11    if myServer <> nil then
12    begin
13      if mysql_options(myServer, MYSQL_OPT_CONNECT_TIMEOUT, '30') = 0 then
14      begin
15        if mysql_real_connect(myServer, 'host', 'user', 'password', 'database', 3306,
16          nil, CLIENT_COMPRESS) <> nil then
17        begin
18          Tables := mysql_list_tables(myServer, nil);
19          if Tables <> nil then
20          begin
21            TableRows := mysql_num_rows(Tables);
22            while TableRows > 0 do
23            begin
24              Table := mysql_fetch_row(Tables);
25              Tabelle := Table[0];
26              Dec(TableRows);
27            end;
28          end;
29        end;
30      end;
31    end;
32  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC