Re: OLEDB not work !

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I get it's source code :)
Delphi6 update2 + MS SQL Server2000 Sp4


unit Conn_Unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DB, ADODB, ExtCtrls,winsock, ShlObj;

type
  TConnForm = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    UserNameEdit: TEdit;
    Label6: TLabel;
    DBNameEdit: TEdit;
    ADOConn: TADOConnection;
    ConnTestBtn: TBitBtn;
    PassWordEdit: TEdit;
    MYIPAddress: TEdit;
    procedure ConnTestBtnClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ConnForm: TConnForm;

implementation

{$R *.dfm}


procedure TConnForm.ConnTestBtnClick(Sender: TObject);
var
IPAddress,DBName,UserName,PassWord,ConnStr:String;
begin

 IPAddress := Trim(MyIPAddress.Text) ;
 DBName    := Trim(DBNameEdit.Text) ;
 UserName  := Trim(UserNameEdit.Text);
 PassWord  := Trim(PassWordEdit.Text);


 if Trim(DBName) = '' then
    begin
     DBNameEdit.SetFocus ;
     Application.MessageBox('Please input database name!','Error');
     Exit;
    end;

 if Trim(UserName) = '' then
    begin
     PassWordEdit.SetFocus ;
     Application.MessageBox('Please input username!','Error');
     Exit;
    end;

 ConnStr:='Provider=SQLOLEDB.1;Password='+PassWord+';Persist Security Info=True;User ID='+UserName+';Initial Catalog='+DBName+';Data Source='+IPAddress;

 ADOConn.Connected :=False;
 ADOConn.ConnectionString :=ConnStr;

   try
   ADOConn.Connected :=True;
   Application.MessageBox('Link To Database!','OK');
   Exit;
   except
   Application.MessageBox('Can not link to database!','Fail');
   Exit;
   end;






end;

procedure TConnForm.FormShow(Sender: TObject);
begin


       MyIPAddress.Text    := '127.0.0.1';
       DBNameEdit.Text     := '';
       UserNameEdit.Text   := '';
       PassWordEdit.Text   := '';

end;

end.






[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux