delphi通过TADOConnection组件直接连接MSSQL数据库并读写数据。
unit Unit1; interface uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Data.Win.ADODB, Vcl.StdCtrls,
Vcl.Grids, Vcl.DBGrids, Vcl.ComCtrls; type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Memo1: TMemo;
Memo2: TMemo;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
var
sObjId,sMemo: string;
sTitle: string;
sauxinfo: string;
TotalNum,recNum,loopNum: Integer;
fetchNum: Integer;
begin
// Initial Catalog 数据库名称
// Data Source 服务器名称或服务器IP
ADOConnection1.ConnectionString := 'Provider=SQLOLEDB.1;Password=admindkl;Persist Security Info=True;User ID=sa;Initial Catalog=infobase;Data Source=127.0.0.1'; //连接指定的数据库
ADOConnection1.LoginPrompt := False;
ADOConnection1.Connected := True; ADOQuery1.Connection := ADOConnection1; //连接数据源 //
recNum:=0;
fetchNum:=1000; while True do
begin
application.ProcessMessages ;
inc(loopNum);
inc(RecNum); with ADOQuery1 do //用ADO组件连接数据表
begin
close;
SQL.Clear;
SQL.Add('Select objid, title,auxinfo,content from ctdsb2015_objs_1 where objid<='+(inttostr(fetchNum+RecNum-1))+' and objid>='+inttostr(RecNum)); //使用SQL语句查询数据表中的内容
open;
end;
ADOQuery1.Active := True; // TotalNum:=ADOQuery1.RecordCount;//1000 RecNum:=fetchNum+RecNum-1; // showmessage(inttostr(TotalNum)); ADOQuery1.First;
richEdit1.Lines.BeginUpdate;
while Not ADOQuery1.Eof do
begin
application.ProcessMessages ;
sObjId:=ADOQuery1.FieldByName('objid').AsString;
sTitle:=ADOQuery1.FieldByName('title').AsString;
sauxinfo:=ADOQuery1.FieldByName('auxinfo').AsString;
sMemo:=pchar(ADOQuery1.FieldByName('content').AsWideString); richEdit1.Lines.Add(sObjId+' === '+sTitle+' === '+sauxinfo+' === '+sMemo); ADOQuery1.Next;
//break;
end; richEdit1.Lines.EndUpdate; if loopNum=3 then break; end;//while true end // DataSource1.DataSet := ADOQuery1;
// DBGrid1.DataSource := DataSource1; showmessage('ok'); end; end.
delphi通过TADOConnection组件直接连接MSSQL数据库并读写数据。的更多相关文章
- SQLServer存储引擎——01.数据库如何读写数据
一.引言 在SQL Server数据库中,数据是如何被读写的?日志里都有些什么?和数据页之间是什么关系?数据页又是如何存放数据的?索引又是用来干嘛的? 一起看看SQL Server的存储引擎. 二.S ...
- Python - Django - form 组件动态从数据库取 choices 数据
app01/models.py: from django.db import models class UserInfo(models.Model): username = models.CharFi ...
- 记一次MSSQL到MySQL大数据迁移过程
工作中遇到一个需求 要将MSSQL数据库中共计12张表的数据大概1000W行数据迁移到MySQL数据库中,去年另一个同事负责这件事情,他采用的方法是先将MSSQL数据库里的数据生成同MySQL数据库表 ...
- Python 学习 第17篇:从SQL Server数据库读写数据
在Python语言中,从SQL Server数据库读写数据,通常情况下,都是使用sqlalchemy 包和 pymssql 包的组合,这是因为大多数数据处理程序都需要用到DataFrame对象,它内置 ...
- TADOConnection组件
该组件用于建立数据库的连接.ADO的数据源组件和命令组件可以通过该组件运行命令及数据库中提取数据等. 该组件用于建立数据库的连接,该连接可被多个数据集所共享,但是并不是应用程序中必须的,因为ADO数据 ...
- PHP连接MSSQL数据库案例,PHPWAMP多个PHP版本连接SQL Server数据库
课前小知识普及:MSSQL和SQL Server是同一个软件,叫法不同而已,MSSQL全称是Microsoft SQL Server,MSSQL是简写,有些人则喜欢直接叫SQL Server,我就比较 ...
- 【转发】PHP连接MSSQL数据库案例,PHPWAMP多个PHP版本连接SQL Server数据库
转发自:http://blog.csdn.net/lccee/article/details/54289076 课前小知识普及:MSSQL和SQL Server是同一个软件,叫法不同而已,MSSQL全 ...
- 一个防止误删MSSQL数据库的方法
一个防止误删MSSQL数据库的方法 环境:Windows2008 R2 .SQL 2012 今天发现一个有趣的现象,之前数据库服务器的其中几个数据库做过镜像,不过现在已经删除了,今天又要在那台服务器上 ...
- MSSQL数据库的一些基础知识
转几个关于MSSQL数据库基础的文章: sql server系统表详细说明 SQL Server中系统数据库介绍 SQL Server中的角色(服务器级别和数据库级别角色)
随机推荐
- sas 基础(1)-关于数据格式的SAS函数
(一)字符转换: 1)字符型转换成数值型 Numvar=INPUT(source,informat) 2)数值型转换成字符型 Chavar=PUT(source,format) (二)字符型变量的处理 ...
- 关于jQuery点击事件叠加问题
先来看个例子: html: <body> <button id="btn">按钮</button> <button id="bt ...
- delphi正则表达式学习笔记(三)
Delphi 中经常使用的正则表达式 在 Delphi 中使用正则表达式, 目前 PerlRegEx 应该是首选, 准备彻底而细致地研究它. 官方网站: http://www.regular-e x ...
- (转)SQL知识_Sql日期时间格式转换
原文地址:http://www.cnblogs.com/Gavinzhao/archive/2009/11/10/1599690.html sql server2000中使用convert来取得dat ...
- 深入理解Apache Flink
Apache Flink(下简称Flink)项目是大数据处理领域最近冉冉升起的一颗新星,其不同于其他大数据项目的诸多特性吸引了越来越多人的关注.本文将深入分析Flink的一些关键技术与特性,希望能够帮 ...
- 《Linux 性能及调优指南》1.6 了解Linux性能指标
翻译:飞哥 (http://hi.baidu.com/imlidapeng) 版权所有,尊重他人劳动成果,转载时请注明作者和原始出处及本声明. 原文名称:<Linux Performance a ...
- Spring Security数据库管理
要实现数据库管理用户角色及权限,需要自定义用户登录功能,Spring Security已经为我们提供了接口UserDetailService.需要以下表: 用户表 角色表 权限表 用户角色关系表 权限 ...
- python-requests数据驱动延伸
在 python-requests模块的讲解和应用 基础上进行数据驱动的延伸 task_01_requests.py #-*- coding:utf-8 -*- #task_01_requests.p ...
- 【Jenkins学习】安装配置和使用(一)
为了能够频繁地将软件的最新版本,及时.持续地交付给测试团队及质量控制团队,以供评审,所以引入持续集成工具Jenkins,从而实现公司新产品持续集成,自动化部署. 环境准备 ●操作系统:Windows1 ...
- 9.Appium使用安装所需软件百度盘链接
Appium使用安装所需软件大全: 1.抓包工具 Charles : 链接:https://pan.baidu.com/s/1KomTDV2_o1dEDvlimrd5HQ 提取码:5yn2 2.抓包工 ...