Subject | TDataSet problem |
---|---|
Author | Marv cook |
Post date | 2004-05-25T17:39:52Z |
Hi all,
I am getting unexpected results with IBO.
Below is a query and two procedures that look identical to me, but
Procedure 1 works correctly and Procedure 2 fails. In Procedure 2 the
open statement never finds any records and is always in the insert mode.
The only difference between them is the use of ParameterByName and
Params[i].
What am I doing wrong?
TIA
Marv
-- TIBOQuery --
SELECT RID
, EMP_ID
, CS_DOW
, TIME_SLOT
, CS_STATUS
, DEPARTMENT_ID
From EMP_DEF_SCHEDULE
WHERE EMP_ID = :empid
and CS_DOW = :csdow
////////////////////////////////
// procedure 1 ///////////////////
Procedure TDMO.SaveDefaultDepartmentCode(empID, DayNumber : integer;
vdepartmentID : integer);
begin
EmpDefScheduleQ.Close;
EmpDefScheduleQ.ParamByName('empid').AsInteger := empID;
EmpDefScheduleQ.ParamByName('csdow').AsInteger := DayNumber;
EmpDefScheduleQ.Open;
if EmpDefScheduleQ.eof then
begin
EmpDefScheduleQ.Insert;
EmpDefScheduleQEMP_ID.asInteger := empID;
EmpDefScheduleQCS_DOW.AsInteger := DayNumber;
end else
begin
EmpDefScheduleQ.Edit;
end;
EmpDefScheduleQDEPARTMENT_ID.AsInteger := vDepartmentID;
EmpDefScheduleQ.Post;
EmpDefScheduleQ.Close;
end;
// Procedure 2 /////////////////
Procedure TDMO.SaveDefaultDepartmentCode(empID, DayNumber : integer;
vdepartmentID : integer);
begin
EmpDefScheduleQ.Close;
EmpDefScheduleQ.Params[0].AsInteger := empID;
EmpDefScheduleQ.Params[1].AsInteger := DayNumber;
EmpDefScheduleQ.Open;
if EmpDefScheduleQ.eof then
begin
EmpDefScheduleQ.Insert;
EmpDefScheduleQEMP_ID.asInteger := empID;
EmpDefScheduleQCS_DOW.AsInteger := DayNumber;
end else
begin
EmpDefScheduleQ.Edit;
end;
EmpDefScheduleQDEPARTMENT_ID.AsInteger := vDepartmentID;
EmpDefScheduleQ.Post;
EmpDefScheduleQ.Close;
end;
////////////////////////////////////
I am getting unexpected results with IBO.
Below is a query and two procedures that look identical to me, but
Procedure 1 works correctly and Procedure 2 fails. In Procedure 2 the
open statement never finds any records and is always in the insert mode.
The only difference between them is the use of ParameterByName and
Params[i].
What am I doing wrong?
TIA
Marv
-- TIBOQuery --
SELECT RID
, EMP_ID
, CS_DOW
, TIME_SLOT
, CS_STATUS
, DEPARTMENT_ID
From EMP_DEF_SCHEDULE
WHERE EMP_ID = :empid
and CS_DOW = :csdow
////////////////////////////////
// procedure 1 ///////////////////
Procedure TDMO.SaveDefaultDepartmentCode(empID, DayNumber : integer;
vdepartmentID : integer);
begin
EmpDefScheduleQ.Close;
EmpDefScheduleQ.ParamByName('empid').AsInteger := empID;
EmpDefScheduleQ.ParamByName('csdow').AsInteger := DayNumber;
EmpDefScheduleQ.Open;
if EmpDefScheduleQ.eof then
begin
EmpDefScheduleQ.Insert;
EmpDefScheduleQEMP_ID.asInteger := empID;
EmpDefScheduleQCS_DOW.AsInteger := DayNumber;
end else
begin
EmpDefScheduleQ.Edit;
end;
EmpDefScheduleQDEPARTMENT_ID.AsInteger := vDepartmentID;
EmpDefScheduleQ.Post;
EmpDefScheduleQ.Close;
end;
// Procedure 2 /////////////////
Procedure TDMO.SaveDefaultDepartmentCode(empID, DayNumber : integer;
vdepartmentID : integer);
begin
EmpDefScheduleQ.Close;
EmpDefScheduleQ.Params[0].AsInteger := empID;
EmpDefScheduleQ.Params[1].AsInteger := DayNumber;
EmpDefScheduleQ.Open;
if EmpDefScheduleQ.eof then
begin
EmpDefScheduleQ.Insert;
EmpDefScheduleQEMP_ID.asInteger := empID;
EmpDefScheduleQCS_DOW.AsInteger := DayNumber;
end else
begin
EmpDefScheduleQ.Edit;
end;
EmpDefScheduleQDEPARTMENT_ID.AsInteger := vDepartmentID;
EmpDefScheduleQ.Post;
EmpDefScheduleQ.Close;
end;
////////////////////////////////////