HOW TO: ?????? ?????? ??? SQL ???????? Visual C# .NET

?????? ????????? ?????? ?????????
???? ???????: 319646 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

????? ??????? ????? ???? ActiveX ????? ???????? ?? SQL Server 2000 ????? ????? ????? ???????? ???? ??????? ?????. ???? ??? ?????? ????? ?????? ?????? ??? SQL ?? Microsoft Visual C# .NET.

?????? 1

??? ????? ????? ???????? ???????? ?? ????? Visual C# .NET ???? ??????? ???????:
  1. ???? ?? ????? ?????? ? ????? ??????? ???? ???? ????? ?? ???? ???? ??? SQL Server 2000.
  2. ????? ????? ??? ???? "SampleMergePublication". ??? ??? ????? ???????? Northwind.

?????? 2

???? ????? ????????? ???????? ?????? ???? ???????? ???? ???? ??? SQL. ????? ?????? ????? ???????? ???????? ????? ?????? ???????? Northwind_replica. ???? ?? ??? ???? ????? ?????? Northwind_replica ?????? ??? ????? ????? ???????? ????????. ???????? ?? ?????? ????? ???????? ???????? ?????? ??? ?? ????? ?????? Northwind_replica ?? ?? ??? ?????? ?????? ?? ??? ???????.

???? ????? Visual C# .NET ????? ????? ??? ???? COM 8.0 ?????? ??? Microsoft SQL ?? ?? ?????? ???????? ???????? ???????:
using System;
using System.Runtime.InteropServices;
using SQLMERGXLib;

namespace SqlRepl
{
	//This class demonstrates using the SQL Server Merge Agent replication control.
	class MergeApp
	{
		/*	Prior to running this code, replication needs to be setup as follows:
		// 	
		//		Create a merge publication called "SampleMergePublication" and configure it to allow pull
		//		subscriptions. 
		//		
		//	This code will first generate the snapshot. Then the subscription database
		//	and pull subscription will be created through code. Then the snapshot will be applied at the subscriber using
		//	the SQLMergeClass object.
		// 
		//	You will also need to set a reference to the following COM dll:
		//		-Microsoft SQL Merge Control 8.0	 
		*/ 
		
		[STAThread]
		static void Main(string[] args)
		{
			string strPublisher, strDistributor, strSubscriber, strPublisherDatabase, strSubscriberDatabase, strPublication;

			strPublisher = "PUBLISHER";		//change to the name of your publisher
			strDistributor = "DISTRIBUTOR";	//change to the name of your distributor
			strSubscriber = "SUBSCRIBER";		//change to the name of your subscriber
			strPublication = "SampleMergePublication";
			strPublisherDatabase = "Northwind";
			strSubscriberDatabase = "Northwind_replica";

			SQLMergeClass oMerge = new SQLMergeClass();
			
			//Set up the Publisher.
			oMerge.Publisher = strPublisher;
			oMerge.PublisherSecurityMode = SQLMERGXLib.SECURITY_TYPE.NT_AUTHENTICATION;
			oMerge.PublisherDatabase = strPublisherDatabase;
			oMerge.Publication = strPublication;

			//Set up the Distributor.
			oMerge.Distributor = strDistributor;
			oMerge.DistributorSecurityMode = SQLMERGXLib.SECURITY_TYPE.NT_AUTHENTICATION;
			
			//Set up the Subscriber.
			oMerge.Subscriber = strSubscriber;
			oMerge.SubscriberDatabase = strSubscriberDatabase;
			oMerge.SubscriberSecurityMode = SQLMERGXLib.SECURITY_TYPE.NT_AUTHENTICATION;

			//Set up the subscription.
			oMerge.SubscriptionType = SQLMERGXLib.SUBSCRIPTION_TYPE.PULL;
			oMerge.SynchronizationType = SQLMERGXLib.SYNCHRONIZATION_TYPE.AUTOMATIC;
			oMerge.SubscriptionName = "PullMergeSubscription";

			//Create the database and subscription.
			oMerge.AddSubscription(SQLMERGXLib.DBADDOPTION.CREATE_DATABASE, SQLMERGXLib.SUBSCRIPTION_HOST.NONE);
			
			//Synchronize the subscription.

			try
			{
				Console.WriteLine("Starting synchronization...");
				oMerge.Initialize();
				oMerge.Run();
				oMerge.Terminate();
				Console.WriteLine("Synchronization completed.");
			}
			catch (Exception e)
			{
				Console.WriteLine(e.StackTrace);
				Console.WriteLine(e.Message);
			}
		}
	}
}

				

?????

?????? ??? ????? Microsoft Visual Basic .NET ?? ??? ???????? ???? 319647.

?????? ??? ????? ???? ??? ??????? ?? ????????? ??????? ?? Microsoft Visual Basic ? Microsoft Visual C++ ? ???? ???????? ??????? "??? SQL Server ???????":

???????

???? ???????: 319646 - ????? ??? ??????: 03/?? ??????/1424 - ??????: 3.6
????? ???
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 64-bit Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
????? ??????: 
kbmt kbhowtomaster KB319646 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????319646

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com