With Delphi 6 i made a program to import tables in Advantage(extended systems) format
It works. If anybody is interested in the code let me know.
The only problem is to import values in the blob field
I am using INSERT INTO
If I use the Fields[i].Value as a string then it doesn't work.
Any suggestions how to do it.
Thanks for your help Teunis
Import BLOB, MEMO from Advantage Table
Try to use parameters with the INSERT INTO statement.
Below is one more way to load a BLOB value:
Below is one more way to load a BLOB value:
Code: Select all
if Query.Fields[i].IsBlob then
TBlobField(Query.Fields[i]).Value := ;Thanks for the answer.
a SQL parameter aproach is difficult to realise because I like to keep the conversion
general.
My working solution is the following for the interested reader:
This works if there is only 1 Blob field in the table.
The table is converted ADS -> MySQL In the INSERT statement the blob fileld is an empty string. The name of the field with ftBLOB is registered and has the name metblob
T1 is the TADSTable Q1 is a TMyQuery sleutel is a primary index field
So after creating the table with her records I fill in the BLOB values.
Teunis
a SQL parameter aproach is difficult to realise because I like to keep the conversion
general.
My working solution is the following for the interested reader:
This works if there is only 1 Blob field in the table.
The table is converted ADS -> MySQL In the INSERT statement the blob fileld is an empty string. The name of the field with ftBLOB is registered and has the name metblob
T1 is the TADSTable Q1 is a TMyQuery sleutel is a primary index field
So after creating the table with her records I fill in the BLOB values.
Code: Select all
IF metblob '' THEN BEGIN
T1.Active:= TRUE;
T1.First;
WHILE NOT T1.Eof DO BEGIN
IF T1.FieldByName(metblob) NIL THEN BEGIN
Q1.SQL.Clear;
Q1.SQL.Add('SELECT * FROM ' + AnsiUpperCase(tafelnaam));
Q1.SQL.Add('WHERE sleutel = ' + T1.FieldByname('sleutel').asString);
Q1.Active:= TRUE;
Q1.Edit;
BlobF:= Q1.FieldByName(metblob) as TBlobField;
BlobF.Assign(T1.FieldByName(metblob) as TBlobField);
Q1.Post;
END;
T1.Next END;
T1.Active:= FALSE;
END;
It is good to see that this problem has been solved
But I think that this way is not optimal. Usage of parameters is more correct and fast. Just assign UPDATE query like this before cycle:
For each BLOB value assign the parameter value for the key field (sleutel_param) and the BLOB value itself (blob_param). Then call to the Q1.Execut method.
But I think that this way is not optimal. Usage of parameters is more correct and fast. Just assign UPDATE query like this before cycle:
Code: Select all
Q1.SQL.Text := 'UPDATE ' + AnsiUpperCase(tafelnaam) + ' SET ' + metblob + '= :blob_param WHERE sleutel = :sleutel_param';Yes Antaeius Thanks for your help.
The following code also works great:
it is als quicker
Thanks Teunis
The following code also works great:
Code: Select all
IF metblob '' THEN BEGIN
Q1.SQL.Text:= 'UPDATE ' + AnsiUpperCase(tafelnaam) +
' SET ' + metblob + '= :blob_param WHERE sleutel = :sleutel_param';
T1.Active:= TRUE;
T1.First;
WHILE NOT T1.Eof DO BEGIN
IF T1.FieldByName(metblob) NIL THEN BEGIN
Q1.params[1].asString:= T1.FieldByname('sleutel').asString;
Q1.Params[0].AsBlob:= T1.FieldByName(metblob).AsVariant;
Q1.Execute;
END;
T1.Next END;
T1.Active:= FALSE;
END;Thanks Teunis