Article View: borland.public.cppbuilder.database.dbexpress
Article #92dbexpress+mySQL4, IT WORKS !
From: Lotfi
Date: Mon, 16 Aug 2004 02:08
Date: Mon, 16 Aug 2004 02:08
232 lines
6011 bytes
6011 bytes
So dbexpress + mySQL 4 :-)
need some configuration of :
dbxdrivers.ini (for default config)
add these :
[Installed Drivers]
MySQLCon=1
[MySQLCon]
GetDriverFunc=getSQLDriverMYSQL
LibraryName=dbexpmysql.dll
VendorLib=libmysql.dll
BlobSize=-1
Database=test
ErrorResourceFile=
HostName=localhost
LocaleCode=0000
Password=
User_Name=root
and to dbxconnections.ini add :
[MySQLamoi]
DriverName=MySQLCon
BlobSize=-1
Database=test
ErrorResourceFile=
HostName=localhost
LocaleCode=0000
Password=
User_Name=root
so in the the project :
mydbexprForm.h
file://---------------------------------------------------------------------
------
#ifndef mydbexprFormH
#define mydbexprFormH
file://---------------------------------------------------------------------
------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <DB.hpp>
#include <DBXpress.hpp>
#include <SqlExpr.hpp>
#include <DBCtrls.hpp>
#include <DBGrids.hpp>
#include <ExtCtrls.hpp>
#include <FMTBcd.hpp>
#include <Grids.hpp>
#include <DBClient.hpp>
#include <Provider.hpp>
file://---------------------------------------------------------------------
------
class TForm1 : public TForm
{
__published: // Composants g�r�s par l'EDI
TSQLConnection *SQLConnection1;
TDataSource *DataSource1;
TDBGrid *DBGrid1;
TDBNavigator *DBNavigator1;
TButton *ButtonOpen;
TDataSetProvider *DataSetProvider1;
TClientDataSet *ClientDataSet1;
TSQLTable *SQLTable1;
TButton *Button1;
void __fastcall ButtonOpenClick(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // D�clarations de l'utilisateur
public: // D�clarations de l'utilisateur
__fastcall TForm1(TComponent* Owner);
};
file://---------------------------------------------------------------------
------
extern PACKAGE TForm1 *Form1;
mydbexprForm.cpp
file://---------------------------------------------------------------------
------
#include <vcl.h>
#pragma hdrstop
#include "mydbexprForm.h"
file://---------------------------------------------------------------------
------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
file://---------------------------------------------------------------------
------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
file://---------------------------------------------------------------------
------
void __fastcall TForm1::ButtonOpenClick(TObject *Sender)
{
ClientDataSet1->Close();
ClientDataSet1->Open();
}
mydbexprForm.dfm (in text mode)
object Form1: TForm1
Left = 391
Top = 228
Width = 525
Height = 355
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 0
Top = 144
Width = 361
Height = 185
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object DBNavigator1: TDBNavigator
Left = 0
Top = 120
Width = 240
Height = 25
DataSource = DataSource1
TabOrder = 1
end
object ButtonOpen: TButton
Left = 192
Top = 40
Width = 75
Height = 25
Caption = 'Open '
TabOrder = 2
OnClick = ButtonOpenClick
end
object Button1: TButton
Left = 304
Top = 40
Width = 75
Height = 25
Caption = 'OpenSQL'
TabOrder = 3
OnClick = Button1Click
end
object SQLConnection1: TSQLConnection
Connected = True
ConnectionName = 'MySQLamoi'
DriverName = 'MySQLCon'
GetDriverFunc = 'getSQLDriverMYSQL'
LibraryName = 'dbexpmysql.dll'
LoginPrompt = False
Params.Strings = (
'DriverName=MySQLCon'
'BlobSize=-1'
'Database=test'
'ErrorResourceFile='
'HostName=localhost'
'LocaleCode=0000'
'Password='
'User_Name=root')
VendorLib = 'libmysql.dll'
Left = 24
Top = 24
end
object DataSource1: TDataSource
DataSet = ClientDataSet1
Left = 144
Top = 24
end
object DataSetProvider1: TDataSetProvider
DataSet = SQLTable1
Constraints = True
Left = 64
Top = 64
end
object ClientDataSet1: TClientDataSet
Aggregates = <>
Params = <>
ProviderName = 'DataSetProvider1'
Left = 96
Top = 64
end
object SQLTable1: TSQLTable
SQLConnection = SQLConnection1
IndexFieldNames = 'id'
TableName = 'ex_1'
Left = 64
Top = 24
end
end
my SQL db "test" has a table "ex_1"
see my website :
for an example with Zeos objects and the database I use :
http://www.baghli.com/bcb_mysql.html
if you don't have the right dlls :
dbexpmysql.dll
and libmysql.dll
I can send them to you by email
Ciao, hope this will help you
Technical Details
Message-ID:
<4120168e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<411bb6d2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: fb4e2,84c3ce95504f366f X-Google-Attributes: gidfb4e2,public X-Google-Language: ENGLISH,ASCII From: "Lotfi" <blotfib(nospam)@free.fr> Newsgroups: borland.public.cppbuilder.database.dbexpress References: <411bb6d2@newsgroups.borland.com> Subject: dbexpress+mySQL4, IT WORKS ! Date: Mon, 16 Aug 2004 04:08:56 +0200 Lines: 234 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4922.1500 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4939.300 NNTP-Posting-Host: 82.66.254.150 Message-ID: <4120168e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1092621966 82.66.254.150 (15 Aug 2004 19:06:06 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail