Ever have greatly advstringgrid updating data to database statement under reference thank you...
Procedure TForm1. Button1Click (Sender: TObject);
Var
J: Integer;
The begin
For j:=1 to AdvStringGrid1. Do the RowCount - 1
The begin
Edit1. Text:=IntToStr (AdvStringGrid1 RowCount);
UniQuery1. Close;
UniQuery1. SQL. The Clear;
UniQuery1. SQL. The Add (' SELECT * FROM dbo. CS_pubstaff ');
UniQuery1. Open;
UniQuery1. Edit;
UniQuery1. FieldByName (' cs_dep). Asstring:=advstringgrid1. Cells [j] 1,;
//UniQuery1 FieldByName (' cs_code). Asstring:=advstringgrid1. Cells [j] 2,;
//UniQuery1 FieldByName (' cs_name). Asstring:=advstringgrid1. Cells [3, j];
UniQuery1. Post;
end;
I like to write only updates a data but also wrong
CodePudding user response:
zijidingxiaCodePudding user response:
VarJ: Integer;
The begin
For j:=1 to AdvStringGrid1. Do the RowCount - 1
The begin
Edit1. Text:=IntToStr (AdvStringGrid1 RowCount);
UniQuery1. SQL. Text:="insert into CS_pubstaff (cs_dep cs_code, cs_name) value (: cs_dep, : cs_code, : cs_name) ';
UniQuery1. The Parameters. ParamByName (' cs_dep). Value:=advstringgrid1. Cells [j] 1,;
UniQuery1. The Parameters. ParamByName (' cs_code). Value:=advstringgrid1. Cells [j] 2,;
UniQuery1. The Parameters. ParamByName (' cs_name). Value:=advstringgrid1. Cells [3, j];
UniQuery1. ExecSQL;
end;
CodePudding user response: