Delphi (Tuxedo,bde,ado) Triad Data Set component Hstxquery

Source: Internet
Author: User

Delphi (Tuxedo,bde,ado) Triad Data Set component Hstxquery

I. BACKGROUND

Why do you want to do this triad data set component? Once our company with Delphi developed systems mostly in Ado,bde way to connect the database, the two sets of components are very convenient and flexible, the cost control is also very friendly, from the past more than 10 years in the use of the problem is not very small, the user does not have three-tier architecture requirements. But when bidding for big companies this year, they tend to be blocked by technical requirements. Party A's bid on the three-storey structure, which makes us very headache, now our company is using tuxedo to do the middle layer, assuming the transformation, then the cost is estimated to be one year, two version number maintenance cost is very high. In the face of this situation, I put forward the idea of a triad, that is, building new data set components. The new component is compatible with all the properties and methods that have been query, just need to replace the query class with the UE editor, and be able to switch between Tuxedo,bde,ado three connections, and the system does not need to maintain a version number. Think sparse only shallow, hope that everyone more generous enlighten, grateful.

Second, the component structure diagram

From the structure diagram can see the use of decorative mode, hstxquery the user's access to the object behind their own, according to the connection to the different objects. It visits tuxedo through HsTxQuery.dll, there is a layer of conversion, and BDE, ADO is directly connected.

Third, the design class

Iv. examples

1. Open

Procedure Tform1.button7click (Sender:tobject);

Begin

Hsquery2.close;

HsQuery2.SQL.Text: = ' select * from users ';

Hsquery2.open;

End

2. Operation

Procedure Tform1.button7click (Sender:tobject);

Begin

Hsquery2.close;

HsQuery2.SQL.Text: = ' Insert test value ';

HsQuery2. Execsql;

End

3. Inserting records

Procedure Tform1.button9click (Sender:tobject);

Var

Ms:tmemorystream;

Begin

MS: = Tmemorystream.create;

Image2.Picture.Graphic.SaveToStream (MS);

With HsQuery2 do

Begin

Database. StartTransaction;

Append;

Hsquery2.fieldbyname (' F1 '). Asstring: = FormatDateTime (' Yyyymmddhhmmss ', now);

Hsquery2.fieldbyname (' F2 '). Asstring: = FormatDateTime (' YYYYMMDD ', now);

Hsquery2.fieldbyname (' F3 '). Asstring: = FormatDateTime (' Hhmmss ', now);

Hsquery2.fieldbyname (' F4 '). Asstring: = ' dashing elder brother ';

Hsquery2.fieldbyname (' F5 '). Asstring: = ' 1 ';

Hsquery2.fieldbyname (' F6 '). Asstring: = ' 330102199001164317 ';

Hsquery2.fieldbyname (' F7 '). Asstring: = ' 1 ';

Hsquery2.setblobstream (Hsquery2.fieldbyname (' Fphoto '), MS);

Post;

Applyupdates;

Commitupdates;

Database.commit;

End

Ms. Free;

End

4. Update record

Procedure Tform1.button10click (Sender:tobject);

Var

Ms:tmemorystream;

Begin

Ms:= tmemorystream.create;

Image2.Picture.Graphic.SaveToStream (MS);

Hsquery2.edit;

Hsquery2.fields.fields[0]. Asstring: = ' 6 ';

HSQUERY2.FIELDS.FIELDS[1]. Asinteger: = 198;

HSQUERY2.FIELDS.FIELDS[2]. Asstring: = ";

HSQUERY2.FIELDS.FIELDS[3]. Asstring: = ' Roy ';

HSQUERY2.FIELDS.FIELDS[4]. Asstring: = ' 1 ';

HSQUERY2.FIELDS.FIELDS[5]. Asstring: = ' 2 ';

Hsquery2.setblobstream (HSQUERY2.FIELDS.FIELDS[6],MS);

Hsquery2.post;

Hsquery2.applyupdates;

Hsquery2.commitupdates;

Ms. Free;

End

5. Delete records

Hsquery2.delete;

6, save/Fetch BLOB data

Save and view the Insert sample.

Procedure Tform1.button8click (Sender:tobject);

Var

Stream:tmemorystream;

Jpg:tjpegimage;

Begin

Stream:=hsquery2.getblobstream (Hsquery2.fieldbyname (' DATA '));

Jpg:=tjpegimage.create;

Stream.position: = 0;

Jpg.         Loadfromstream (Stream); Loading pictures

Image2. Picture.assign (JPG);

End

7. Get field values

Procedure Tform1.button15click (Sender:tobject);

Begin

ShowMessage (Hsquery2.fieldbyname (' userid '). asstring);

ShowMessage (Hsquery2.fields.fields[0]. asstring);

End

8. Filter

Here is the filter

Hsquery2.filter: = ' userid=102 ';

Hsquery2.filtered: = true;

The following are anti-filtering

Hsquery2.filter: = ";

Hsquery2.filtered: = true;

9. Number of references

/

Procedure Tform1.button16click (Sender:tobject);

Begin

With Hsquery2 do

Begin

Close

Sql.clear;

Sql. Text: = ' Select * from users where USERID =: id ';

Parambyname (' id '). Value: = 106;

Open

End

End

10, Tuxedo, BDE and ADO mode dynamic switching

/

Procedure Tform1.combobox1change (Sender:tobject);

Begin

Case ComboBox1. ItemIndex of

0:

Begin

Hsquery2.datasettype: = Dttuxedo;

Hsquery2.connectionstring: = '//192.168.1.121:8887 ';

End

1:

Begin

Hsquery2.datasettype: = Dtbde;

Hsquery2.connectionstring: = ' ORCL ';

Hsquery2.connection: = Database1;

End

2:

Begin

Hsquery2.datasettype: = Dtado;

Hsquery2.connectionstring: = ' provider=oraoledb.oracle.1; PASSWORD=GF; Persist Security info=true; User Id=gf;data SOURCE=ORCL; Extended properties= "";

Hsquery2.connection: = ADOConnection1;

End

End

End

V. Outlook

A lot of middleware for data exchange, such as various MQ, can be packaged into easy-to-use components to make life better for developers.

Development sample Please increase QQ Group:69024049 for request and discussion.

Delphi (Tuxedo,bde,ado) Triad Data Set component Hstxquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.