Delphi2007中使用DbExpress连接MySql的例子

新建数据库
/*
MySQL Data Transfer
Source Host: localhost
Source Database: blog
Target Host: localhost
Target Database: blog
Date: 2008/04/15 16:18:41
*/


SET  FOREIGN_KEY_CHECKS = 0 ;
--  ----------------------------
--
 Table structure for posts
--
 ----------------------------
CREATE   TABLE  `posts` (
  `id` 
int ( 10 ) unsigned  NOT   NULL  auto_increment,
  `title` 
varchar ( 50 default   NULL ,
  `body` 
text ,
  `created` 
datetime   default   NULL ,
  `modified` 
datetime   default   NULL ,
  
PRIMARY   KEY   (`id`)
) ENGINE
= MyISAM AUTO_INCREMENT = 6   DEFAULT  CHARSET = utf8;

--  ----------------------------
--
 Records 
--
 ----------------------------
INSERT   INTO  `posts`  VALUES  ( ' 1 ' ' The title ' ' This is the post body. ' ' 2008-04-08 11:51:46 ' null );
INSERT   INTO  `posts`  VALUES  ( ' 2 ' ' A title once again ' ' And the post body follows. ' ' 2008-04-08 11:51:46 ' null );
INSERT   INTO  `posts`  VALUES  ( ' 3 ' ' Title strikes back ' ' This is really exciting! Not. ' ' 2008-04-08 11:51:46 ' null );

Delphi2007中新建工程,页面上追加TSimpleDataSet及TDataSource控件。

然后做如下设置

 

字段直接可以拉到页面上的,如下:

设置各个控件间的DataSource属性。后台代码:

使用 DbExpress 的时候总感觉很别扭。网上也有很多人说这套组件有潜在BUG存在。不知道是不是真的有李维大师所说的那样好。

注意:关于事务:使用StartTransaction方法的话需要用到TTransactionDesc类,这需要在开头uses部追加SqlExpr。

如果换成BeginTransaction方法的话需要用到TDBXTransaction类,这需要在开头uses部追加DBXCommon。

从警告信息可以判断,Delphi2007已经开始不推荐使用StartTransaction方法做事务处理了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值