Delphi Under the Local Area Network SQL Server and Database

xiaoxiao2021-03-06  107

Unit umain;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Extctrls, Dxcntner, DxEditor, DxExedtr, Dxedlib, Stdctrls, Comctrls, COMOBJ, Buttons;

type TfrmMain = class (TForm) Panel1: TPanel; Bevel1: TBevel; Bevel2: TBevel; Bevel4: TBevel; Label1: TLabel; HostName: TdxPickEdit; Label2: TLabel; DataBaseName: TdxPickEdit; GroupBox1: TGroupBox; Label3: TLabel; dxEdit1: TdxEdit ; BitBtn1: TBitBtn; BitBtn2: TBitBtn; Label4: TLabel; Label5: TLabel; UserID: TdxEdit; UserPass: TdxEdit; Label6: TLabel; PassLogin: TRadioButton; NtLogin: TRadioButton; procedure HostNameDropDown (Sender: TObject); procedure BitBtn2Click (Sender: TObject); procedure DataBaseNameDropDown (Sender: TObject); procedure NtLoginClick (Sender: TObject); procedure PassLoginClick (Sender: TObject); private {Private declarations} public {public declarations} end;

Var frmmain: tfrmmain;

IMPLEMentation

{$ R * .dfm}

Procedure tfrmmain.hostnamedropdown (Sender: Tobject); Var SQLServer: Variant; ServerList: Variant; i, Nservers: integer

begin if HostName.Items.Count <1 then begin HostName.Items.Clear; SQLServer: = CreateOleObject ( 'SQLDMO.Application'); ServerList: = SQLServer.ListAvailableSQLServers; nServers: = ServerList.Count; for i: = 0 to nservers -1 Do Hostname.Items.Add (ServerList.Item (i)); sqlserver: = null; serverList: = null; end; end; procedure tfrmmain.bitbtn2click (sender: TOBJECT); begin close;

procedure TfrmMain.DataBaseNameDropDown (Sender: TObject); var SQLServer: Variant; Server: Variant; db: Variant; i, j: integer; begin SQLServer: = CreateOleObject ( 'SQLDMO.Application'); Server: = CreateOleObject ( 'SQLDMO. SQLServer '); if NtLogin.Checked then begin Server.LoginSecure: = True; // set to the registration mode WINDOWS Server.Connect (HostName.Text); Server.IntegratedSecurity.SecurityMode: = 1; Server.DisConnect; Server.Stop; While Server.Status <> 3 do begin end; server.Start (true, hostname.text); end else begin server.loginsecure: = true; // Set to mix login mode server.connect (Hostname.Text); Server. IntegratedSecurity.securitymode: = 2; server.disconnect; server.stop; while server.status <> 3 do Begin end; server.Start (True, hostname.text); end; db: = server.database; i: = db.count; DatabaseName.Items.clear; for j: = 1 to i do databaseename.Items.Add ( db.Item (j) .name;

Server: = null; sqlserver: = null; db: = null;

Procedure tfrmmain.ntloginclick (sender: TOBJECT); begin if ntlogin.checked = true dam Userid.enable; = false; userpass.enabled: = false;

END;

procedure TfrmMain.PassLoginClick (Sender: TObject); begin if PassLogin.Checked = True then begin UserID.Enabled: = True; UserPass.Enabled:. = True; end; end; end control program used for the expansion of Developer Express Inc Control. After testing can pass two login methods

转载请注明原文地址:https://www.9cbs.com/read-102719.html

New Post(0)