delphi8中怎么没有ADO控件啊
解决方案 »
- 初学 请教
- 自己写的从DBGRID导入EXCEL的程序,为什么只能导25个字段,多了就不行。实在没办法了,请高手指点。谢谢!!
- ■■■ 关于写 ini文件里奇怪的问题????
- 哪位大虾帮下
- 有没有哪位高手帮我写一个USSD(移动业务)有API和协议,高分相送!
- 还问加密技术:可以对中文进行加密解密吗?----------高分求!
- 用qrexpr计算SQL Server2000中几个类型为money的字段的和,则qrexpr.Value的类型是什么?怎么把它转为real型?
- 如何让Memo组件没有输入焦点呢?
- "Cannot perform this operation on a closed dataset"怎么回事?
- 怎样用存储过程的参数?
- 请问谁有换系统皮肤的控件!
- 有关包含窗体的DLL的调用问题
也不知道是不是默认没有安装
知道D8是干吗的吗?
这个版本没有ado控件
不过听说没ado
不是Delphi8 for Win32
所以没有ADO,只有ADO.net
看来用delphi的都不关注delphi的变化啊,
borland几个月前就声明了d8只for dotnet,就也就意味着不会有ado了。
那还是要用D6或D7了:)
强要人用DBEXPREESS
而且那东东开发一个东东真麻烦!
1、使用VCL For .Net:这种方式目前不支持ADO.Net!!!
2、使用Windows Form:这种方式支持ADO.Net,但VCL For .Net那些控件将不能继续使用!!!
// 文件名:DBOperate.pas
//
// 类名:数据库操作类
// 描述:用于实现数据库的基本操作功能
//
// 作者:Win Lai
// 创建日期:2003-12-11
// 修改日期:2003-12-18
//
// 在Delphi6.0编译通过
//
// 使用:
//
// 1.定义类对象。
// MyClass : TDBOperate;
//
// 2.分配空间给类对象。
// MyClass := TDBOperate.Create(nil);
//
// 3.建立数据库链接。
// MyClass.ConnectionStrings := '[数据库链接串]'
// MyClass.Connect
//
// 4.操作数据库。
// MyClass.SQLStrings := '[SQL语句]'
// MyClass.SQLExec
// MyClass.SQLOpen
//
// 5.链接数据库控件。
// MyClass.DataSource.DateSet := MyClass.ADOTable;
// [数据库控件].DataSource := MyClass.DataSource;
//
// 6.释放类对象。
// MyClass.Free;
//
//-------------------------------------------------------------------------unit DBOperate;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ADODB, DB;type
TDBOperate = class(TObject) private
FADOConnection: TADOConnection;
FADOQuery: TADOQuery;
FADOTable: TADOTable;
FDataSource: TDataSource; FConnectionStrings: string;
FSQLStrings: string;
protected public
constructor Create(AOwner: TComponent); virtual;
destructor Destroy; override; procedure Connect;
procedure SQLExec;
procedure SQLOpen; function Disconnect: boolean;
function IsConnected: boolean; property ADOConnection: TADOConnection read FADOConnection write FADOConnection;
property ADOQuery: TADOQuery read FADOQuery write FADOQuery;
property ADOTable: TADOTable read FADOTable write FADOTable;
property DataSource: TDataSource read FDataSource write FDataSource;
property ConnectionStrings: string read FConnectionStrings write FConnectionStrings;
property SQLStrings: string read FSQLStrings write FSQLStrings;
end;implementation//-------------------------------------------------------------------------
// 构造函数
constructor TDBOperate.Create(AOwner: TComponent);
begin
inherited Create();
//..
FADOConnection := TADOConnection.Create(nil);
FADOQuery := TADOQuery.Create(nil);
FADOTable := TADOTable.Create(nil);
FDataSource := TDataSource.Create(nil); FADOConnection.LoginPrompt := false; // 不显示登录框
end;//-------------------------------------------------------------------------
// 析构函数
destructor TDBOperate.Destroy;
begin
//..
Disconnect;
FADOConnection.Free;
FADOQuery.Free;
FADOTable.Free;
FDataSource.Free; inherited Destroy;
end;//-------------------------------------------------------------------------
// 链接数据库
procedure TDBOperate.Connect;
begin
// 已经链接
if IsConnected=true then
begin
exit
end; try
FADOQuery.Connection := FADOConnection;
FADOTable.Connection := FADOConnection; FADOConnection.Close;
FADOConnection.ConnectionString := FConnectionStrings;
FADOConnection.Open; if FADOConnection.Connected = false then
begin
// 链接数据库失败
Application.MessageBox('链接数据库失败!', '错误', MB_OK OR MB_ICONERROR);
Application.Terminate;
end;
except
Application.MessageBox('链接数据库失败!', '错误', MB_OK OR MB_ICONERROR);
Application.Terminate;
end;
end;//-------------------------------------------------------------------------
// 断开链接数据库
function TDBOperate.Disconnect: boolean;
begin
// 已经断开链接
if IsConnected=false then
begin
Result := true;
exit;
end; try
FADOConnection.Close;
Result := true;
except
Result := false;
end;
end;//-------------------------------------------------------------------------
// 检查是否链接数据库
function TDBOperate.IsConnected: boolean;
begin
if ADOConnection.Connected = false then
Result := false
else
Result := true;
end;//-------------------------------------------------------------------------
// 执行SQL语句,不返回数据集
procedure TDBOperate.SQLExec;
begin
FADOQuery.Close;
FADOQuery.SQL.Text := FSQLStrings;
FADOQuery.ExecSQL;
end;//-------------------------------------------------------------------------
// 执行SQL语句,可返回数据集
procedure TDBOperate.SQLOpen;
begin
FADOQuery.Close;
FADOQuery.SQL.Text := FSQLStrings;
FADOQuery.Open;
end;//-------------------------------------------------------------------------
end.