SQL Server replication Programming

Source: Internet
Author: User
{
First install the activx control: component-> Import ActiveX Control-> Microsoft SQL Merge Control 8.0 (version 1.0)-> install
Large DBMS such as SQL Server and Oracle all provide the copy function. Replication can be performed between heterogeneous databases. It can be said that it is very universal.
In this example, SQL Server2000 is installed on the server, Access2000 is installed on the cash register, and the copy mode is merged.
Some settings are stored in the specified INI file in the client programming mode, which is flexible and convenient.
}

Unit unit1;

Interface

Uses
Windows, messages, sysutils, variants, classes, graphics, controls, forms,
Dialogs, olectrls, sqlmergxlib_tlb, stdctrls, buttons;

Type
Tform1 = Class (tform)
Merge: tsqlmerge;
Bitbtn1: tbitbtn;
Procedure bitbtn1click (Sender: tobject );
Private
{Private Declarations}
Public
{Public declarations}
End;

VaR
Form1: tform1;

Implementation

{$ R *. DFM}

// Place a "Synchronize" button on the client
Procedure tform1.bitbtn1click (Sender: tobject );
Begin
Try
With merge do
Begin
// Publishing Server
Publisher: = 'cxg'; // name of the Publishing Server
Publisherdatabase: = 'ynckjxc '; // publish a database
Publication: = 'stristriket'; // publish
Publishersecuritymode: = nt_authentication; // security verification

// Distribution server
Distributor: = 'cxg'; // distributor name
Distributorsecuritymode: = nt_authentication;

// Subscribe Server
Subscriber: = 'cxg'; // subscriber name
Subscriberdatabasepath: = 'C:/data/ynjxc. mdb '; // subscribe to the database
Subscriberdatasourcetype: = jet4_database;
Subscribersecuritymode: = db_authentication;
Subscriberlogin: = 'admin ';
Subscriberpassword: = '';

// Subscription Method
Subscriptiontype: = anonymous; // anonymous subscription
Synchronizationtype: = automatic;

// Bidirectional synchronization between the publishing server and the subscription Server
Initialize;
Run;
Terminate;
End;
Showmessage ('success ');
Except
Showmessage ('failed ');
End;
End;

End.

Related Article

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.