Delphi2007中使用DbExpress连接MySql的例子
2008-04-15 16:58
696 查看
新建数据库
/**//*
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方法做事务处理了。
/**//*
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方法做事务处理了。
相关文章推荐
- Delphi XE8中的DBExpress使用ODBC方式连接MySQL 5.6.24 X64!!!!
- 使用Connector/C++(VS2015)连接MySQL的完整例子
- Delphi XE8中的DBExpress使用ODBC方式连接MySQL 5.6.24 X64!!!!
- MySQL 使用 SSL 连接(附 Docker 例子)
- Delphi XE中使用dbExpress连接MySQL数据库疑难问题解决(对三层的例子配置有帮助)
- Hibernate4使用映射文件hbm.cml连接访问MySQL的小例子
- Java使用jdbc连接和操作mysql的例子
- delphi xe 之路(27)XE7 Datasnap使用dbExpress连接MySQL
- MySQL 使用 SSL 连接(附 Docker 例子)
- Hibernate4使用Annotation连接访问MySQL的小例子
- Hibernate4使用Annotation连接访问MySQL的小例子
- jdbc链接mysql的第二个例子。使用properties文件存放连接信息。使用jar文件一个
- 使用VS2010连接MySQL
- PHP 通过MYSQL扩展库 连接MYSQL例子
- hive使用mysql localstore方式连接Access denied for user 'hive'@'localhost' to database
- Java与Mysql6的jdbc连接例子
- JAVA使用JDBC连接数据库做JSON封装和解析的例子
- 如何使用navicat for mysql连接本地数据库,并且导入数据文件
- 【坑】使用db.properties后不能正常连接mysql
- MySQL 使用 SSL 连接配置详解