From Volume II of the SQL Joes 2 Pros Exam Prep Series for Exam 70-433. How to design Many-to-Many relationship.
CREATE TABLE IF NOT EXISTS `Movies` ( `ID` int(11) NOT NULL AUTO_INCREMENT , `Title` varchar(255) NOT NULL , `ImdbUrl` varchar(255) DEFAULT NULL , `Picture` blob , PRIMARY KEY (`ID`) , KEY `Title` (`Title`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
UPDATE Movies SET Picture=:Picture WHERE ID=:IDCheck that qCmd has two parameters, Picture and ID, by opening its Params property in object inspector.
procedure TForm1.btnAddPictSQLClick(Sender: TObject); var vFileStream: TStream; begin // do we have record to store the picture to? Don't continue if not if tblMovies.IsEmpty then Exit; // do the user select a picture file? Dont continue if not if not OpenPictureDialog1.Execute then Exit; // load the picture file into a stream vFileStream := TFileStream.Create(OpenPictureDialog1.FileName, fmOpenRead or fmShareDenyNone); try // give ID of the current movie record to the :ID parameter of qCmd qCmd.[B]Params[/B].ParamByName('ID').Value := tblMoviesID.Value; // Assign the content of FS stream to the :Picture parameter qCmd.[B]Params[/B].ParamByName('Picture').LoadFromStream(vFileStream, ftBlob); // execute the sql qCmd.[B]ExecSQL[/B]; // refresh the table so it shows the new picture RefreshTable; finally vFileStream.Free; end; end;
Download Pertama2 kita harus punya file installernya terlebih dahulu, download https://github.com/fortesinformatica/fortesrepo...