+ -
当前位置:首页 → 问答吧 → deliph连接数据库

deliph连接数据库

时间:2011-09-24

来源:互联网

deliph连接数据库老是说连接属性错误,晕死了,求大师解决代码如下:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,Grids,DBGrids,DB,ADODB,Stdctrls,ExtCtrls;

type
  TForm1 = class(TForm)
  vdbfname: TEdit;
  Label1: TLabel;
  Label2: TLabel;
  vservername: TEdit;
  Label3: TLabel;
  vusername: TEdit;
  Label4: TLabel;
  upassword: TEdit;
  vtablename: TComboBox;
  Label5: TLabel;
  bottom1: TButton;
  botton2: TButton;
  ADOConnection1: TADOConnection;
  DBGrid1: TDBGrid;
  DataSource1: TDataSource;
  ADOTable1: TADOTable;
  procedure buttom1click(sender:tobject);
  procedure botton2click(sender:tobject);

  private
  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
  procedure TForm1.buttom1click(sender: TObject);
  var
  s:string;
  begin
  adoconnection1.Connected:=false;
  s:='Provider=SQLOLEDB.1;Password='+trim(upassword.text)+';Persist Security Info=True;';
  s:=s+'User ID='+trim(vusername.text)+';Initial Catalog='+trim(vdbfname.text)+';Data Source='+trim(vservername.text)+';';
  s:=s+'Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;';
  s:=s+'Use Encryption for Data=False;Tag with column collation when possible=False';
  adoconnection1.connectionstring:=s;
  adoconnection1.loginprompt:=false;
  adoconnection1.connectiontimeout:=3;
  adoconnection1.connected:=true;
  adotable1.Active:=false;
  adotable1.Connection:=adoconnection1;
  adotable1.TableName:=trim(vtablename.Text);
  adotable1.Active:=true;
  datasource1.DataSet:=adotable1;
  dbgrid1.datasource:=datasource1;
  vservername.SetFocus;
  end;
  procedure tform1.botton2click(sender: TObject);
  begin
  close;
  end;


end.

作者: cllmxy   发布时间: 2011-09-24

用什么 ADO 连数据库啊。你下个组件, UniDac 支持多种数据库,无需配 ODBC

下载地址
http://download.csdn.net/detail/netcreate/3517299

作者: netcreate   发布时间: 2011-09-24