我以前用的是BDE。没有用过ADO。现在想用ADO。但不知道怎么用。
我有一下几个问题:
一、我用的是D5.上面有这样几个1、ADOConnection、2、ADOCommand、
3、ADODataSet、4、ADOTABLE 5、ADOStoredProc 6、RDSConnection。是什么东西。
怎么设置才能使用。(详细操作)
二、连接SQL SERVER 注意什么?
三、连接ACCESS怎么连?不用ODBC?
(要存取数据快的方案)
我有一下几个问题:
一、我用的是D5.上面有这样几个1、ADOConnection、2、ADOCommand、
3、ADODataSet、4、ADOTABLE 5、ADOStoredProc 6、RDSConnection。是什么东西。
怎么设置才能使用。(详细操作)
二、连接SQL SERVER 注意什么?
三、连接ACCESS怎么连?不用ODBC?
(要存取数据快的方案)
1 是用来连接数据库用。4 与TABLE相似5 用来执行 存储过程
二注意有两种连接,一是用WIN2000验证,一是用管理员验证
2.注意网络通讯
3.网上的组件很多,用组件吧
1\连接ado数据库
2、执行ado命令行
3、连接的数据库的数据集
4、数据库中数据表
5、ado存储过程
6、远程的ado连接三、
可以用ole-db连接
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
labelededit1: TEdit;
labelededit2: TEdit;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
str:string;
begin
if (labelededit1.Text<>'') and (labelededit2.Text<>'') then
begin
//连接远程服务器:str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=数据库名称'+';'+'Data Source=服务器名称';str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog='+edit2.Text+';'+'Data Source='+EDIT1.Text;ADOConnection1.ConnectionString:=str;ADOConnection1.Open;labelededit2.Text:='';
Button1.Enabled:=false;end;end;procedure TForm1.Button2Click(Sender: TObject);
begin
ADOConnection1.Close;Button1.Enabled:=true;end;end.
下一篇::
用ADOConnection连接到具体数据库: procedure Tloginmain.Button1Click(Sender: TObject);varstr:string;beginif (labelededit1.Text<>'') and (labelededit1.Text<>'') thenbegin//连接远程服务器:str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=数据库名称'+';'+'Data Source=服务器名称';str:='Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'+';'+'User ID='+LabeledEdit1.Text+';'+'Password='+labelededit2.text+';'+'Initial Catalog=testdase';ADOConnection1.ConnectionString:=str;ADOConnection1.Open;labelededit2.Text:='';end;end;断开数据库:
procedure Tloginmain.Button2Click(Sender: TObject);beginADOConnection1.Close;Button1.Enabled:=true; end;
具体连接到数据库的某个表可以用:ADODataSet将ADODataSet的Connection属性设置为:ADOConnection将ADODataSet的CommandType属性设置为:cmdTableif not loginmain.ADODataSet1.Active thenbeginADODataSet1.CommandText:='worker_information';//worker_information为表名ADODataSet1.Open;end;
有向导直接选择就会搞定的
其他的ADODataset等都连接ADOConnection的
http://soft.at.9966.org