Replication with host_name

Hello,

   I am wanting to limit the amount of rows that are merged between the server and the wm device. Host_name() doesn't seem to be supported in sql mobile. I created a column called host and set the default value as host_name(). I get the table to replicate however when I try to insert into the table on the mobile side I get errors. Is there another option to filter like this or if I hard code a deviceID how can I add this to the filter rows options Thanks.

John

 

Table script:

CREATE TABLE [dbo].[tstHost](

[peoplid] [numeric](18, 0) NOT NULL,

[image] [image] NULL,

[host] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_tstHost_host] DEFAULT (host_name()),

[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [MSmerge_df_rowguid_F9DD287E09FF4064813E154D2F0ACBC6] DEFAULT (newsequentialid()),

CONSTRAINT [PK_tstHost] PRIMARY KEY CLUSTERED

(

[peoplid] ASC

)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

 

Query on sql mobile side:

insert into tsthost (peopleid) values (2)

Error:

FAILED: insert into tsthost (peopleid) values (2)< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Error: 0x80040e14 DB_E_ERRORSINCOMMAND

Native Error:  (25503)

Description: The column name is not valid. [,,,Node name (if any),Column name,]

Interface defining error: IID_ICommand

Param. 0: 0

Param. 1: 0

Param. 2: 0

Param. 3:

Param. 4: peopleid

Param. 5:



Answer this question

Replication with host_name

  • Mijaelovic

    HOST_NAME is absolutely supported in SQL Mobile.

    Here is actual code using it:

    Public Function GetReplication() As SqlCeReplication

    Dim repl As SqlCeReplication = Nothing

    Try
    repl = New SqlCeReplication()

    repl.InternetUrl = Configuration.GetAppSetting("REPLICATION_URL")
    repl.Publisher = Configuration.GetAppSetting("REPLICATION_PUBLISHER")
    repl.PublisherDatabase = Configuration.GetAppSetting("REPLICATION_PUBLISHER_DB")
    repl.PublisherSecurityMode = SecurityType.NTAuthentication
    repl.Publication = Configuration.GetAppSetting("REPLICATION_PUBLICATION")
    repl.Subscriber = Configuration.GetAppSetting("REPLICATION_SUBSCRIBER")
    repl.SubscriberConnectionString = Configuration.GetAppSetting("REPLICATION_SUBSCRIBER_CONNECTION_STRING")
    repl.HostName = Globals.GetInstance().TechnicianID

    If Not System.IO.File.Exists(_dbmsFile) Then
    repl.AddSubscription(AddOption.CreateDatabase)
    End If

    Catch ex As Exception
    DisplaySQLCEErrors(ex)
    Return Nothing
    End Try

    Return repl

    End Function

    -Darren



  • Replication with host_name