for i := stringgrid1.rowcount - 1 to 1 do
begin
query1.UpdateObject := UpdateSQL1;
query1.sql.BeginUpdate;
query1.SQL.Add('update dsclgo set sc_outnumber = :number,');
query1.sql.add('sc_item = :item, sc_qty = :qty, sc_dan = :dan,');
query1.sql.add('sc_amt = :amt');
query1.sql.add('where sc_outnumber =' + cmboutnumber.text );
query1.SQL.EndUpdate;
query1.ParamByName('number').DataType := ftString;
query1.ParamByName('number').Value := trim(cmboutnumber.Text);
query1.ParamByName('item').DataType := ftstring;
query1.parambyname('item').value := stgrdout.Cells[0,i];
query1.ParamByName('qty').DataType := ftstring;
query1.parambyname('qty').value := stgrdout.Cells[1,i];
query1.parambyname('dan').datatype := ftString;
query1.parambyname('dan').value := stgrdout.cells[2,i];
query1.parambyname('amt').datatype := ftstring;
query1.parambyname('amt').value := stgrdout.cells[3,i];
query1.Prepare;
query1.ApplyUpdates;
end;
코딩을 위와 같이 했습니다.
콤보박스로 선택되어진 데이터들을 스트링그리드로 뿌리고 난다음
그 상태에서 편집버튼을 클릭합니다. 그리고 나서 스트링 그리드에서 데이타들을 수정하고 난 다음 저장버튼을 눌렀을때 데이터가 수정이 되지 않습니다. 코드는 위와 같이 했구요 updatesql을 사용하는 방법을 잘 모릅니다.
질문 1) updatesql을 동적으로 사용하는 방법
: 연결되어진 query1가 동적으로 연결되기 때문
2) 위의 코딩에 문제가 있으면 알려주시기를 바랍니다.
> for i := stringgrid1.rowcount - 1 to 1 do
> begin
> query1.UpdateObject := UpdateSQL1;
> // 필요없음 query1.sql.BeginUpdate;
> query1.SQL.Add('update dsclgo set sc_outnumber = :number,');
> query1.sql.add('sc_item = :item, sc_qty = :qty, sc_dan = :dan,');
> query1.sql.add('sc_amt = :amt');
> query1.sql.add('where sc_outnumber =' + cmboutnumber.text );
> // 필요없음 query1.SQL.EndUpdate;
>
>// query1.ParamByName('number').DataType := ftString;
>// query1.ParamByName('number').Value := trim(cmboutnumber.Text);
// 밑에처럼 한줄로 Optimize
query1.ParmaByName('number').asString := trim(cmboutnumber.Text);
> query1.ParamByName('item').DataType := ftstring;
> query1.parambyname('item').value := stgrdout.Cells[0,i];
> query1.ParamByName('qty').DataType := ftstring;
> query1.parambyname('qty').value := stgrdout.Cells[1,i];
> query1.parambyname('dan').datatype := ftString;
> query1.parambyname('dan').value := stgrdout.cells[2,i];
> query1.parambyname('amt').datatype := ftstring;
> query1.parambyname('amt').value := stgrdout.cells[3,i];
>
>
> query1.Prepare;
> // query1.ApplyUpdates; ApplyUpdates 란 Transaction 을 쓸때
// 쓰는거지..이런식으로 쓰는것이 아님다.
query1.ExecSQL;
>
>
> end;
>
> 코딩을 위와 같이 했습니다.
> 콤보박스로 선택되어진 데이터들을 스트링그리드로 뿌리고 난다음
> 그 상태에서 편집버튼을 클릭합니다. 그리고 나서 스트링 그리드에서 데이타들을 수정하고 난 다음 저장버튼을 눌렀을때 데이터가 수정이 되지 않습니다. 코드는 위와 같이 했구요 updatesql을 사용하는 방법을 잘 모릅니다.
> 질문 1) updatesql을 동적으로 사용하는 방법
> : 연결되어진 query1가 동적으로 연결되기 때문
> 2) 위의 코딩에 문제가 있으면 알려주시기를 바랍니다.
>