I am busy making an important IT Project for my class and I am struggling to succeed trough this one problem.
The program needs to Store Images to the table of the database, but I am trying to use a different technique. When the user uses the 'loadfromfile' control, the directory of the File Name is used instead of saving the Picture itself into the database. So I have a field in the table called : "Directory" that only reads a string and I am storing the File name path into that field, like 'C:/Pictures/Picture.JPG' etc.
I use sName by an edit.text to let the user find the specific record to save the path to the field. And sDirectory for the path name itself.
I use a MS Access database table. In the table fields : (ID, Real Name, Surname,Pass,Age,Directory,Medium,Location,Artwork Name)
Once the user chooses the Picture from the Loadfromfile dialogue, the user needs to save the path into the specific record that the user wants to save. I tried using this code but it keeps giving me a Syntax error :
Syntax error(missing operator) in query expression 'Username = 'the Name' Insert (Directory) Values(?)'
procedure TfrmPost.btnBrowseClick(Sender: TObject);
begin
opdImage.Execute;
sDirectory := opdImage.FileName;
MyPic.Picture.LoadFromFile(sDirectory);
bitBtnUpload.Enabled := true;
end;
procedure TfrmPost.bitBtnUploadClick(Sender: TObject);
begin
sName := lblName.Caption;
sDirectory := QoutedStr(opdImage.Filename);
with dmArt do
begin
qryArt.Close;
qryArt.SQL.Clear;
qryArt.SQL.Text := 'SELECT * FROM tbArt WHERE Username = '''+sName + ''' ';
qryArt.Open;
qryArt.SQL.Add('Insert');
qryArt.SQL.Add('(Directory)');
qryArt.SQL.Add('Values (:Directory)');
qryArt.Parameters.ParamByName('Directory').Value := sDirectory;
qryArt.ExecSQL;
qryArt.Close;
end;
end;