?? uadoset.pas
字號:
sql.Text:=strSql;
if paramValues.Count<>0 then
begin
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
end
else
begin
end;
prepared;
ExeCSql;
end;//with
Finally
AdoQuery.Close;
end;
end;////
/////做數(shù)據(jù)表進行更新操作//////////////////////////////////
procedure UpdateRecord(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList);
var
i:integer;
begin
with AdoQuery do
begin
try
ConnectionString:=ConnectToDatabase(2);
close;
sql.clear;
sql.Text:=strSql;
if paramValues.Count<>0 then
begin
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
end
else
begin
end;////
prepared;
ExeCSql;
Finally
AdoQuery.Close;
end;
end;//with
end;////
/////驚醒存盤///////////////////////////////////////////
procedure SaveRecord(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList);
var
i:integer;
begin
with AdoQuery do
begin
try
ConnectionString:=ConnectToDatabase(2);
close;
sql.clear;
sql.Text:=strSql;
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
prepared;
ExeCSql;
Finally
AdoQuery.Close;
end;
end;//with
end;///
/////將數(shù)據(jù)綁頂?shù)娇丶?///////////////////////////////////
procedure BindToGrid1(AdoQuery:TAdoQuery;strSql:string;Ctrl:TControl);
var
i:integer;
j:integer;
ListItem:TListItem;
begin
try
with Adoquery do
begin
ConnectionString:=ConnectToDatabase(2);
try
close;
except
ON E:exception do
begin
exit;
end;
end;
sql.clear;
///strSql:='SELECT * FROM '+TableName+' WHERE '+FieldName+'=:'+FieldName;
Sql.Text:=strSql;
prepared;
Open;
if RecordCount<>0 then
begin
///1./////將數(shù)據(jù)綁定到控件EasyGrid////////
if (ctrl is TEasyGrid) then
begin
//////清空表格中的數(shù)據(jù)////////////////
for j:=2 to TEasyGrid(ctrl).RowCount-2 do
begin
for i:=1 to TEasyGrid(ctrl).ColCount-1 do
begin
TEasyGrid(ctrl).Cells[i,j].ForeText:='';
end;///i
end;///j
///////////////////////////////////////
first;
//////////////////////////////////////
TEasyGrid(ctrl).ColCount:=FieldList.Count+1;
TEasyGrid(ctrl).RowCount:=Recordcount+2;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
for i:=0 to FieldList.Count-1 do
begin
TEasyGrid(ctrl).Cells[i+1,j+1].ForeText:=FieldByName(FieldDefList[i].Name).asstring;
end;
next;
inc(j);
end;///while
TEasyGrid(ctrl).Refresh;
end;///if (ctrl is)結(jié)束
///2.將數(shù)據(jù)綁定到控件stringGrid///////////////////////////////////
if (ctrl is TStringGrid) then
begin
//////清空表格中的數(shù)據(jù)////////////////
for j:=1 to TStringGrid(ctrl).RowCount-2 do
begin
for i:=1 to TStringGrid(ctrl).ColCount-1 do
begin
TStringGrid(ctrl).Cells[i,j]:='';
end;///i
end;///j
///////////////////////////////////////
first;
//////////////////////////////////////
TStringGrid(ctrl).ColCount:=FieldList.Count+1;
TStringGrid(ctrl).RowCount:=Recordcount+2;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
for i:=0 to FieldList.Count-1 do
begin
TStringGrid(ctrl).Cells[i+1,j]:=FieldByName(FieldDefList[i].Name).asstring;
end;
next;
inc(j);
end;///while
///TEasyGrid(ctrl).Refresh;
end;///if 結(jié)束
////2.結(jié)束//////////////////////////////////////////////////////////////
////3.將數(shù)據(jù)綁定到控件ListView///////////////////////////////////////////
if (ctrl is TListView) then
begin
TListView(ctrl).Clear;
//FieldIndex:=0;
first;
while not eof do
begin
listitem:=TlistView(ctrl).Items.Add;
for i:=0 to FieldList.Count-2 do
begin
//listitem.Caption:=FieldValues[FieldDefList[0].Name];
if not FieldbyName(FieldDefList[i+1].Name).IsNull then
begin
listitem.SubItems.Add(FieldValues[FieldDefList[i+1].Name]);
end;
end;//for
next;
end;///while
end;///if(ctrl is Listview)結(jié)束///
////3.結(jié)束///////////////////////////////////////////////////////////////
end;////if
end; //with
Finally
AdoQuery.Close;
end;
end;/////
////將符合條件的記錄顯示記錄集///////////////////////////
procedure BindToGrid(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList;Ctrl:TControl);
var
i:integer;
j:integer;
ListItem:TListItem;
begin
try
with Adoquery do
begin
ConnectionString:=ConnectToDatabase(2);
try
close;
except
ON E:exception do
begin
exit;
end;
end;
sql.clear;
///strSql:='SELECT * FROM '+TableName+' WHERE '+FieldName+'=:'+FieldName;
Sql.Text:=strSql;
if paramValues.Count<>0 then
begin
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
end
else
begin
end;////
prepared;
Open;
if RecordCount<>0 then
begin
///1./////將數(shù)據(jù)綁定到控件EasyGrid////////
if (ctrl is TEasyGrid) then
begin
//////清空表格中的數(shù)據(jù)////////////////
for j:=2 to TEasyGrid(ctrl).RowCount-2 do
begin
for i:=1 to TEasyGrid(ctrl).ColCount-1 do
begin
TEasyGrid(ctrl).Cells[i,j].ForeText:='';
end;///i
end;///j
///////////////////////////////////////
first;
//////////////////////////////////////
TEasyGrid(ctrl).ColCount:=FieldList.Count+1;
TEasyGrid(ctrl).RowCount:=Recordcount+3;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
////showmessage('asas');
for i:=0 to FieldList.Count-1 do
begin
////showmessage(FieldByName(FieldDefList[i].Name).asstring);
TEasyGrid(ctrl).Cells[i+1,j+1].ForeText:=trim(FieldByName(FieldDefList[i].Name).asstring);
end;
next;
inc(j);
end;///while
TEasyGrid(ctrl).Refresh;
end;///if (ctrl is)結(jié)束
///2.將數(shù)據(jù)綁定到控件stringGrid///////////////////////////////////
if (ctrl is TStringGrid) then
begin
//////清空表格中的數(shù)據(jù)////////////////
for j:=1 to TStringGrid(ctrl).RowCount-2 do
begin
for i:=1 to TStringGrid(ctrl).ColCount-1 do
begin
TStringGrid(ctrl).Cells[i,j]:='';
end;///i
end;///j
///////////////////////////////////////
first;
//////////////////////////////////////
TStringGrid(ctrl).ColCount:=FieldList.Count+1;
TStringGrid(ctrl).RowCount:=Recordcount+2;
j:=1;
while (not eof) and (j<=Recordcount) do
begin
for i:=0 to FieldList.Count-1 do
begin
TStringGrid(ctrl).Cells[i+1,j]:=FieldByName(FieldDefList[i].Name).asstring;
end;
next;
inc(j);
end;///while
///TEasyGrid(ctrl).Refresh;
end;///if 結(jié)束
////2.結(jié)束//////////////////////////////////////////////////////////////
////3.將數(shù)據(jù)綁定到控件ListView///////////////////////////////////////////
if (ctrl is TListView) then
begin
TListView(ctrl).Clear;
//FieldIndex:=0;
first;
while not eof do
begin
listitem:=TlistView(ctrl).Items.Add;
for i:=0 to FieldList.Count-2 do
begin
//listitem.Caption:=FieldValues[FieldDefList[0].Name];
if not FieldbyName(FieldDefList[i+1].Name).IsNull then
begin
listitem.SubItems.Add(FieldValues[FieldDefList[i+1].Name]);
end;
end;//for
next;
end;///while
end;///if(ctrl is Listview)結(jié)束///
////3.結(jié)束///////////////////////////////////////////////////////////////
end;////if
end; //with
Finally
AdoQuery.Close;
end;
end;////
//////得到某一字段值/////////////////////////////////
Function getFieldValue(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList;FieldName:string):variant;
var
i:integer;
begin
///FieldName:=TStringList.Create;
try
with Adoquery do
begin
ConnectionString:=ConnectToDatabase(2);
try
close;
except
ON E:exception do
begin
exit;
end;
end;
sql.clear;
///strSql:='SELECT * FROM '+TableName+' WHERE '+FieldName+'=:'+FieldName;
Sql.Text:=strSql;
if paramValues.Count<>0 then
begin
for i:=0 to paramValues.count-1 do
begin
Parameters[i].value:=paramValues[i];
end;
end
else
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -