ADOQuery1 - & gt; The Parameters - & gt; ParamByName (" waveform ") - & gt; LoadFromFile (" c: \ \ temp \ \ temp. The seed ", ftBlob);
The temp file. The seed is the standard of 512 bytes long, but after writing database field length increases the 2 bytes 0 (0 d a), each row of data is in this way, could you tell me how to guarantee the LoadFromFile method is used to read data is file length of 512? Please master to help me!
Bcb6.0 mysql server
CodePudding user response:
ADOQuery1 - & gt; Edit ();
TBlobField * bf=(TBlobField *) ADOQuery1 - & gt; FieldByName (" waveform ");
TADOBlobStream * bs=new TADOBlobStream (bf, bmWrite);
Bs - & gt; Seek (0, soFromBeginning);
Bs - & gt; LoadFromFile (" c: \ \ temp \ \ temp seed ");
ADOQuery1 - & gt; Post ();
The delete bs;
CodePudding user response:
Moderator demon elder brother good, first thank you for your warm help,I did, in accordance with the method of demon elder brother of the Parameters of the source code is the use of ADO I ParamByName assignment, inser fields in the original more than 23, if the demon elder brother FieldByName change momentum is big, I still according to the Parameters of ADO, simplifies some fields, only two fields to illustrate, specific code is as follows:
Void __fastcall TForm1: : write_DB (SEED_data_record * SEED_data_record)
{
ADOQuery1 - & gt; Close ();
ADOQuery1 - & gt; SQL - & gt; The Clear ();
ADOQuery1 - & gt; SQL - & gt; Text="insert into waveform_con (id, Waveform) values (t1, : t20)";
ADOQuery1 - & gt; The Parameters - & gt; ParamByName (" t1 ") - & gt; Value=https://bbs.csdn.net/topics/1;
TBlobField * bf=(TBlobField *) ADOQuery1 - & gt; The Parameters - & gt; T20 ParamByName (" ");
TADOBlobStream * bs=new TADOBlobStream (bf, bmWrite);
Bs - & gt; Seek (0, soFromBeginning);
Bs - & gt; LoadFromFile (" c: \ \ temp \ \ temp seed ");
ADOQuery1 - & gt; ExecSQL ();
The delete bs;
}
According to the above code to the
TADOBlobStream * bs=new TADOBlobStream (bf, bmWrite);
This sentence is wrong, I don't know where the cause of the error? You also need to master to help me,
Error prompt:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Seedp
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Access violation at address 6 d614e04. Read of address 6 d614e04.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sure
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CodePudding user response:
How no one to help? Master to help me!I'm in the data flow, the length is fixed in the blob field of 512 bytes, now more than 0 0 a "d", no problem, try so hard ah, I today in accordance with the method of demon elder brother to write the program, or no problem, I think may be ADOQuery1 - & gt; The Parameters - & gt; ParamByName (" waveform ") - & gt; LoadFromFile () method is not suitable for, can you tell me the master have other ways to write blob?
CodePudding user response:
The blog you fields to store data, 0 d 0 a 0 x0 characters behind? So, if the text processing, is only the front carriage returns the two bytes,CodePudding user response:
Demon elder brother good,Is to have two carriage returns a newline, should not be handled as a text file, I don't know how to deal with this problem, it should also be
I saw the other methods, the Internet seems to be suitable for my request, is the TBlobSTream * TemplateStream; But in the following way pass the compilation, always out of the question,
.
#include
#include
#include
Void __fastcall TForm1: : write_DB (SEED_data_record * SEED_data_record)
{
.
TBlobSTream * TemplateStream;
ADOQuery1 - & gt; The Open ();
ADOQuery1 - & gt; Edit ();
ADOQuery1 - & gt; Append ();
Sprintf (no_temp, "% 5 d," ADOQuery1 - & gt; RecordCount + 1);
ADOQuery1 - & gt; FieldByName (" id ") - & gt; Value=https://bbs.csdn.net/topics/no_temp;
TemplateStream=new TBlobStream ((TBlobField *) ADOQuery1 - & gt; FieldByName (" Waveform "), bmReadWrite);
TemplateStream - & gt; Write ((char *) seed_data_record, 512);
.
ADOQuery1 - & gt; Post ();
}
Why I've included a TBlobSTream required header files, still shows no TBlobSTream defined at compile time?
[Error] c + + E2451 Undefined symbol 'TBlobSTream
'
TBlobSTream compares what size?
CodePudding user response:
The pictures before I split into several files, content can also be added 0 0 d a, to now also don't know is what reason, estimates that this reason with youCodePudding user response:
On the Internet to see other people the same question, he is such a solution:TBlobStream * TemplateStream=(TBlobStream *) ADOQuery1 - & gt; CreateBlobStream (ADOQuery1 - & gt; FieldByName (" Waveform "), bmReadWrite);
I do not know why, anyway, so, I also shall be dealt with in accordance with this,
But
ADOQuery1 - & gt; FieldByName (" id ") - & gt; Value=https://bbs.csdn.net/topics/no_temp;
TemplateStream - & gt; Write ((char *) seed_data_record, 512);//seed_data_record is a standard 512 bytes of data
.
ADOQuery1 - & gt; Post ();
.
Waveform of blob field has not been written into the data, what's wrong with the is? Please people!