Board index » delphi » database update problem with D6 ADO/VCL, ADO v2.6, and MS Access2000

database update problem with D6 ADO/VCL, ADO v2.6, and MS Access2000

I have a rather simple database with a few tables and relationships.  I'm
trying to use a ADO command or query component to execute UPDATE sql
statement with query parameters.  The problem is the database is not being
updated.  When the execute method is called on the command component it
doesn't return an error message, and nothing is changed in the database.
Any advice or assistance would be greatly appreciated...

Here is a snip of the sql statement from the command component:
<snip>
UPDATE tbl_Locations
SET
    tbl_Locations.LocationName = :prmLocationName,
    tbl_Locations.LocationNameUName= :prmLocationNameUName
    tbl_Locations.LocationAddress1 = :prmLocationAddress1,
    tbl_Locations.LocationAddress2 = :prmLocationAddress2,
    tbl_Locations.LocationAddress3 = :prmLocationAddress3,
    tbl_Locations.City = :prmCity,
    tbl_Locations.State = :prmState,
    tbl_Locations.PostalCode = :prmPostalCode
WHERE (tbl_Locations.LocationsAutoID = :prmLocationsAutoID);
</snip>

Here is a snip of the update function:
<snip>
Function TdmodInventoryMngrData.UpdateLocation( LocationName,
LocationNameUCase, LocStreetAdd1,

LocStreetAdd2, LocStreetAdd3, LocCity,

LocState, LocPostalCode : String;

LocationID : Cardinal ) : Boolean;
begin
  try
    {--- set the query parameters ---}
    {--- execute the query ---}
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationsAutoID' ).Value
:= LocationID;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationName' ).Value :=
LocationName;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationNameUName' ).Value
:= LocationNameUCase;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationAddress1' ).Value
:= LocStreetAdd1;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationAddress2' ).Value
:= LocStreetAdd2;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationAddress3' ).Value
:= LocStreetAdd3;
    cmdUpdateLocation.Parameters.ParamByName( 'prmCity' ).Value := LocCity;
    cmdUpdateLocation.Parameters.ParamByName( 'prmState' ).Value :=
LocState;
    cmdUpdateLocation.Parameters.ParamByName( 'prmPostalCode' ).Value :=
LocPostalCode;
    cmdUpdateLocation.Execute;

    {--- declare the operation a success ---}
    Result := True;
  except
    {--- catch exceptions here and declare the operation a failure ---}
    Result := false;
  end;
end;
</snip>

 

Re:database update problem with D6 ADO/VCL, ADO v2.6, and MS Access2000


I have a rather simple database with a few tables and relationships.  I'm
trying to use a ADO command or query component to execute UPDATE sql
statement with query parameters.  The problem is the database is not being
updated.  When the execute method is called on the command component it
doesn't return an error message, and nothing is changed in the database.
Any advice or assistance would be greatly appreciated...

Here is a snip of the sql statement from the command component:
<snip>
UPDATE tbl_Locations
SET
    tbl_Locations.LocationName = :prmLocationName,
    tbl_Locations.LocationNameUName= :prmLocationNameUName
    tbl_Locations.LocationAddress1 = :prmLocationAddress1,
    tbl_Locations.LocationAddress2 = :prmLocationAddress2,
    tbl_Locations.LocationAddress3 = :prmLocationAddress3,
    tbl_Locations.City = :prmCity,
    tbl_Locations.State = :prmState,
    tbl_Locations.PostalCode = :prmPostalCode
WHERE (tbl_Locations.LocationsAutoID = :prmLocationsAutoID);
</snip>

Here is a snip of the update function:
<snip>
Function TdmodInventoryMngrData.UpdateLocation( LocationName,
LocationNameUCase, LocStreetAdd1,

LocStreetAdd2, LocStreetAdd3, LocCity,

LocState, LocPostalCode : String;

LocationID : Cardinal ) : Boolean;
begin
  try
    {--- set the query parameters ---}
    {--- execute the query ---}
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationsAutoID' ).Value
:= LocationID;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationName' ).Value :=
LocationName;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationNameUName' ).Value
:= LocationNameUCase;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationAddress1' ).Value
:= LocStreetAdd1;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationAddress2' ).Value
:= LocStreetAdd2;
    cmdUpdateLocation.Parameters.ParamByName( 'prmLocationAddress3' ).Value
:= LocStreetAdd3;
    cmdUpdateLocation.Parameters.ParamByName( 'prmCity' ).Value := LocCity;
    cmdUpdateLocation.Parameters.ParamByName( 'prmState' ).Value :=
LocState;
    cmdUpdateLocation.Parameters.ParamByName( 'prmPostalCode' ).Value :=
LocPostalCode;
    cmdUpdateLocation.Execute;

    {--- declare the operation a success ---}
    Result := True;
  except
    {--- catch exceptions here and declare the operation a failure ---}
    Result := false;
  end;
end;
</snip>

Other Threads