国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ADO帶密碼的數據連接、查詢一個記錄集、執行一SQL語句

2019-11-18 18:14:48
字體:
來源:轉載
供稿:網友

unit UDataModule;

interface

uses
   Controls,SysUtils, Classes, DB, ADODB,windows,forms,CustomCom_TLB;

type
  TDataModule1 = class(TDataModule)
    ADOConnection1: TADOConnection;
    dsDataSet: TADODataSet;
    ADOQuery1: TADOQuery;
    PRocedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public
    ConnOK:boolean;
    { Public declarations }
  end;

var
  DataModule1: TDataModule1;
  loginMan : string;
  loginManID:integer;
  isManager:boolean;
  myCom : ICustomMG ; // COM 對象
  function OpenSQL(s: string;query:TADODataSet):integer;
  function DoSQL(s: string;query:TADOQuery):boolean;
 
implementation

{$R *.dfm}

procedure TDataModule1.DataModuleCreate(Sender: TObject);
var SQL,pwd:string;
begin
  //連接ADO
  try
    pwd := 'deliSerial';
    SQL := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+
         extractfilepath(paramstr(0))+'SerialInfo.mdb'+
         ';Persist Security Info=False;'  +
         'Jet OLEDB:Database PassWord="'+pwd+'"';
    ADOConnection1.Connected := false;
    ADOConnection1.ConnectionString := SQL;
    ADOConnection1.Connected := true;
    ConnOK:=true;
  except
    ConnOK:=false;
  end;
end;

function OpenSQL(s: string;query:TADODataSet):integer;
var old_Cursor:TCursor;
begin
  old_Cursor:=screen.cursor;
  screen.cursor:=crSQLWait;
  try
    try
      with query do
      begin
        close;
        commandtext:=s;
        open;
        result:=query.recordcount;
      end;
    except
     result:=0;
    end;
  finally
    screen.cursor:=old_Cursor;
  end;
end;

function DoSQL(s: string;query:TADOQuery):boolean;
var old_Cursor:TCursor;
begin
  result:=true;
  old_Cursor:=screen.cursor;
  screen.cursor:=crSQLWait;
  try
    try
      with query do
      begin
        close;
        SQL.Clear ;
        SQL.Add(s);
        ExecSQL;
      end;
    except
      result:=false;
    end;
  finally
    screen.cursor:=old_Cursor;
  end;
end;

end.


上一篇:文件與目錄

下一篇:合理應用用戶登錄界面,用戶登錄時不必創建其他窗體

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 乐安县| 南投县| 永和县| 久治县| 墨脱县| 神农架林区| 东阳市| 府谷县| 曲水县| 乌拉特中旗| 公主岭市| 澄迈县| 施甸县| 四川省| 罗甸县| 潮安县| 珲春市| 阳原县| 名山县| 潮州市| 新巴尔虎左旗| 封开县| 凉山| 句容市| 光泽县| 子洲县| 探索| 佛坪县| 衢州市| 内江市| 闵行区| 延长县| 巍山| 大竹县| 永安市| 前郭尔| 永清县| 灌云县| 台南县| 葵青区| 霍州市|