交友约会| 杂志期刊| 小说| 论坛| 电影下载| 两性知识| 电脑知识| 汽车| 旅游| 收藏

ADO带密码的数据连接、查询一个记录集、执行一SQL语句

来源: 作者: 出处:综艺读书 2007-03-26 
关 键 词:word  windows  os  dos  

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.

更多文章 更多内容请看Cisco密码恢复专题  SQL Server 索引和查询专题  电脑密码设置手册专题,或进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
综艺读书宗旨
相关专题
·电脑密码设置手册 (991篇文章)
·Cisco密码恢复专题 (2654篇文章)
·SQL Server 索引和查询专题 (2630篇文章)
热点标签: word  windows  os  dos  
最新技术文档
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
百度推荐,商机无限
搜索您感兴趣的内容
Web 全站
综艺电脑频道编辑信箱  告诉我们您想看的专题或文章

友情互链 | 收藏本站 | 联系我们 | 在线留言 | 京ICP备08008424号|