📄 datalinkunit.~pas
字号:
unit DataLinkUnit;
interface
uses
SysUtils, Classes, DB, ADODB,Windows,Forms;
type
TDM = class(TDataModule)
conMain: TADOConnection;
private
{ Private declarations }
public
{ Public declarations }
Function AdoQueryOpen(strSQL:String;AdoQuery:TAdoQuery;strQueryType:String;strDbType:string):Boolean;
procedure Connect;
end;
var
DM: TDM;
implementation
uses ConfigUnit;
{$R *.dfm}
{ TDM }
////////////////////////////////////// ////////////////////////////////////////
//函数功能:打开数据表(执行数据表) //
//输入参数: //
//SqlStr—SQL字符串,AdoQuery—数据连接串,QueryType—0-打开(1-执行), //
//BeginCol—开始列,LastCol—结束列 //
//输出参数: //
//无 //
//编写人: //
//编写日期:2001.6.2 //
////////////////////////////////////// ////////////////////////////////////////
function TDM.AdoQueryOpen(strSQL: String; AdoQuery: TAdoQuery;
strQueryType, strDbType: string): Boolean;
begin
try
AdoQuery.Close;
except
end;
case strToint(strQueryType) of
1: AdoQuery.Connection:=conMain;
end;
AdoQuery.Close;
AdoQuery.SQL.Clear;
AdoQuery.SQL.Text:=strSQL;
try
if strQueryType='0' then
AdoQuery.Open//打开数据表
else if strQueryType='1' then
begin
AdoQuery.Prepared;
AdoQuery.ExecSQL;//执行数据表
end;
except on E: Exception do
begin
if Pos('primary key',E.Message)<>0 then
Application.MessageBox('主键重复!','错误',mb_OK+mb_IconStop)
else
Application.MessageBox('数据表操作失败!','错误',mb_OK+mb_IconStop);
Result:=False;
Exit;
end;
end;
Result:=True;
end;
procedure dm.Connect;
begin
with conMain do
begin
Close ;
LoginPrompt := False ;
ConnectionString := IniOptions.databasepath ;
Open ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -