Hi
I am pulling my hair out, I am trying to update a table using an ado query, I am using Delphi 5 as a front end and the DB is Access 2003, I have written the app in access and it works fine but I thought I would try to write a front end in Delphi. I will endeavour to explain what I am trying to do
I want to update two columns of dates (The data type is text)
The dates represent testing dates(LastTested and DueTesting)
The dates are 91 days appart
I want to update LastTested to the current date and DueTesting 91 days later
my coding idea is roughly as follows
I keep getting an error message that the parameter is incorrectly defined any help would be much appreciated. I have used the ParamsByName in the past with ADOQuerys but never as an update and never using multiple parametersCode:ADOConnection1.Connected :=True; With ADOQuery1 do begin SQL.Clear; SQL.Text :='Update MCPTestDetails Set LastTested := (:dteparam) and DueTesting := (:dteparam2) Where DueTesting = (;dteParam) '; Parameters.ParamByName('dteparam').Value := DateToStr(Monthcalendar1.Date); Parameters.ParamByName('dteparam2').Value := DateToStr((Monthcalendar1.Date)+91); ExecSQL; Post; close; end; ADOConnection1.Connected :=False;
Last edited by WingedPanther; 08-23-2008 at 07:20 AM. Reason: add code tags
Your SQL statement is invalid. SQL doesn't have a := operator. Try this instead:
You'll have to play around with whether Access requires single quotes around dates, or any other special formatting. Using a showmessage to view the SQL you're about to send, and testing it in Access is a VERY helpful strategy.Code:ADOConnection1.Connected :=True; With ADOQuery1 do begin SQL.Clear; SQL.Text :='Update MCPTestDetails Set LastTested = '+DateToStr(Monthcalendar1.Date)+' and DueTesting = '+DateToStr((Monthcalendar1.Date)+91)+' Where DueTesting = (;dteParam) '; ExecSQL; Post; close; end; ADOConnection1.Connected :=False;
Hi WingedPanther
Many thanks for that it was very helpful
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks