Sun, 11 Dec 2005 19:41:17 GMT
Blob Ado Mysql => Not working properly
I can't make blob work with MySQL database using TADOQuery component. I always get "invalid type" error when trying to assign a value to the field corresponding to the blob type column. Any idea ? I use MySQL 3.23.49 running on my laptop running Windows-Me 4.90.3000. I'm connected using MySQL ODBC driver 2.50.39.00 with Delphi 7 ADO components and MDAC 2.70.9001.0 which comes with Delphi 7 build 4.453. Code used to insert a row in the table: procedure TForm2.AddRowButtonClick(Sender: TObject); var LinesStream : TStream; begin ADOQuery1.Close; ADOQuery1.SQL.Clear; ADOQuery1.SQL.Add('INSERT INTO Documents(DocId, DocDate, DocClass, DocLines) ' + 'VALUES(:DocId, :DocDate, :DocClass, :DocLines)'); ADOQuery1.Parameters.ParamByName('DocId').Value := 'ABCD'; ADOQuery1.Parameters.ParamByName('DocDate').Value := '22/09/2002'; ADOQuery1.Parameters.ParamByName('DocClass').Value := 'Test'; LinesStream := TMemoryStream.Create; LinesStream.Write('Hello World', 11); LinesStream.Seek(0,0); ADOQuery1.Parameters.ParamByName('DocLines').LoadFromStream(LinesStream, ftBlob); // INVALID TYPE ERROR HERE LinesStream.Destroy; ADOQuery1.ExecSQL; ADOQuery1.Close; end; Code used to create the table: procedure TForm2.CreateTableButtonClick(Sender: TObject); begin ADOQuery1.Close; ADOQuery1.SQL.Add( 'CREATE TABLE Documents (' + 'DocId VARCHAR(8) PRIMARY KEY, ' + 'DocDate DATETIME, ' + 'DocClass VARCHAR(20), ' + 'DocLines BLOB ) ' ); ADOQuery1.ExecSQL; ADOQuery1.Close; end; Thanks for you advice.
|