新建数据库
/**/
/*
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 );
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方法做事务处理了。