程式目的:
使用時僅需一行程式碼即可執行SQL語法。程式碼:
function NSQLExec(vcn,vSQL:string):integer;//vcn指定連結不同資料庫,vSQL:SQL語法var vQuery:TADOQuery;//動態產生之TADOQuery
begin
vQuery:=TADOQuery.Create(mainform);//動態產生TADOQuery
vQuery.EnableBCD:=False;
if vcn='cnSYS' then vQuery.Connection:=mainform.cnSYS//依傳入之參數選擇連結設定於mainform之資料庫
else if vcn='cnGroup' then vQuery.Connection:=mainform.cnGroup
else if vcn='cnHR' then vQuery.Connection:=mainform.cnHr;
vQuery.Close;
vQuery.SQL.Text:=vSQL;//傳入SQL語法
result:=vQuery.ExecSQL;//傳回影響筆數
FreeAndNil(vQuery);//關閉動態產生TADOQuery
end;
沒有留言:
張貼留言