Showing posts with label mobile. Show all posts
Showing posts with label mobile. Show all posts

Friday, March 23, 2012

How to Setup Merge replication with sql express

I have a Windows Mobile aplication that uses merge replication to synchronize between sql compact and full sql Enterprise edition and It works great. Instantiating the SqlCeReplication object setting it's properties and calling Synchronize on it is pretty simple assuming everything is setup properly at the publisher.

For the life of me I can't figure out how to do this on the desktop (Programatically setup a subscription and create a database using objects in the System.Replication Namespace and hopefully call Synchronize on it).

Someone please point me in the right direction.

Thanks,


Patrick

See topic "Programming with Replication Management Objects", http://msdn2.microsoft.com/en-us/library/ms146869(SQL.90).aspx.

|||

Look at the MergeSynchronizationAgent class.

Here is some sample code in C#:

Code Snippet

_mergeAgent = newMergeSynchronizationAgent();

_mergeAgent.Publication = _publication;

_mergeAgent.Publisher = _publisher;

_mergeAgent.PublisherDatabase = _publisherDB;

_mergeAgent.PublisherSecurityMode = SecurityMode.Integrated;

_mergeAgent.Distributor = _distributor;

_mergeAgent.DistributorLogin = _distributorLogin;

_mergeAgent.DistributorPassword = _distributorPassword;

_mergeAgent.DistributorSecurityMode = SecurityMode.Standard;

_mergeAgent.Subscriber = _subscriber;

_mergeAgent.SubscriberDatabase = _subscriberDB;

_mergeAgent.SubscriberLogin = _subscriberLogin;

_mergeAgent.SubscriberPassword = _subscriberPassword;

_mergeAgent.SubscriberSecurityMode = SecurityMode.Standard;

_mergeAgent.SubscriptionType = SubscriptionOption.Pull;

_mergeAgent.LoginTimeout = _LoginTimeOut;

_mergeAgent.QueryTimeout = _QueryTimeOut;

_mergeAgent.Synchronize();

Hope this helps!

Wednesday, March 21, 2012

How to set upload only from sql mobile?

Hi,
I am using SQL 2005 in merge-replication with sql mobile. Can anyone tell me
a way to set the transaction for upload from pocket pc only?
Thanks,
Luke
You can set the ExchangeType to 1 and this will do uploadOnly.
You can set this either at the client side or as a profile parameter.
Hope that helps
--Mahesh
[ This posting is provided "as is" with no warranties and confers no
rights. ]
"luke" <talktomyfriend@.hotmail.com> wrote in message
news:edxyEGUEHHA.4280@.TK2MSFTNGP04.phx.gbl...
> Hi,
> I am using SQL 2005 in merge-replication with sql mobile. Can anyone tell
> me a way to set the transaction for upload from pocket pc only?
> Thanks,
> Luke
>

Monday, March 12, 2012

How to set the default value for a datetime culomn?

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

If you want to insert current datetime by calling getdate() method, then it is possible in sql server everywhere. you can do like this;

insert into employee values (4,'John',25, getdate())

This will insert current datetime in the fourth column (in above example).

Please let me know if it answers your question.

Thanks

Sachin

|||

It is just getdate()

Not (getdate())

|||do u mean in sql werver or in asp.net|||Duh ,

He encapsulated it in an expression which started with a ( and so it ended with a ) It is correct. He did not just use the function getdate() as you indicated here.

How to set the default value for a datetime culomn?

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

If you want to insert current datetime by calling getdate() method, then it is possible in sql server everywhere. you can do like this;

insert into employee values (4,'John',25, getdate())

This will insert current datetime in the fourth column (in above example).

Please let me know if it answers your question.

Thanks

Sachin

|||

It is just getdate()

Not (getdate())

|||do u mean in sql werver or in asp.net|||Duh ,

He encapsulated it in an expression which started with a ( and so it ended with a ) It is correct. He did not just use the function getdate() as you indicated here.

How to set the default value for a datetime culomn?

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

If you want to insert current datetime by calling getdate() method, then it is possible in sql server everywhere. you can do like this;

insert into employee values (4,'John',25, getdate())

This will insert current datetime in the fourth column (in above example).

Please let me know if it answers your question.

Thanks

Sachin

|||

It is just getdate()

Not (getdate())

|||do u mean in sql werver or in asp.net|||Duh ,

He encapsulated it in an expression which started with a ( and so it ended with a ) It is correct. He did not just use the function getdate() as you indicated here.

How to set the default value for a datetime culomn?

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

If you want to insert current datetime by calling getdate() method, then it is possible in sql server everywhere. you can do like this;

insert into employee values (4,'John',25, getdate())

This will insert current datetime in the fourth column (in above example).

Please let me know if it answers your question.

Thanks

Sachin

|||

It is just getdate()

Not (getdate())

|||do u mean in sql werver or in asp.net|||Duh ,

He encapsulated it in an expression which started with a ( and so it ended with a ) It is correct. He did not just use the function getdate() as you indicated here.

How to set the default value for a datetime culomn?

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

If you want to insert current datetime by calling getdate() method, then it is possible in sql server everywhere. you can do like this;

insert into employee values (4,'John',25, getdate())

This will insert current datetime in the fourth column (in above example).

Please let me know if it answers your question.

Thanks

Sachin

|||

It is just getdate()

Not (getdate())

|||do u mean in sql werver or in asp.net|||Duh ,

He encapsulated it in an expression which started with a ( and so it ended with a ) It is correct. He did not just use the function getdate() as you indicated here.

Wednesday, March 7, 2012

How to set Merge Repl properties for multiple servers?

Hello...
Currently we have merge replication set up between SQL 2000 and mobile
devices running SQL CE 2.0...and some with SQL Mobile.
As part of the logic on the device, we have to set some properties for the
SqlCeReplication object. Some of these we make dynamic, like the
publication, login, etc.
However, we currently hard code the Publisher and InternetURL values to our
existing server like:
repl.Publisher = "MyMachineName"
repl.InternetURL =
"http://MyMachineName.domain.com/SqlRepl/sqlcesa20.dll"
My question or problem is this...what happens in the case of a failover? We
have a backup/redundant/mirrored server at a different geographic
location...obviously it has a different server name. For the devices in the
field, how do people handle this type of situation where the server failover
will occur automatically. Or, if we decide to move to a server farm...where
we have multiple Sql Servers...how can we make our mobile application
agnostic to the Publisher?
Thanks for any help or advice.
- will
The best way to do this is to put your publisher on a cluster.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"dw" <dw@.discussions.microsoft.com> wrote in message
news:D241EC93-AFFF-4024-B342-99AF1C4E82D4@.microsoft.com...
> Hello...
> Currently we have merge replication set up between SQL 2000 and mobile
> devices running SQL CE 2.0...and some with SQL Mobile.
> As part of the logic on the device, we have to set some properties for the
> SqlCeReplication object. Some of these we make dynamic, like the
> publication, login, etc.
> However, we currently hard code the Publisher and InternetURL values to
our
> existing server like:
> repl.Publisher = "MyMachineName"
> repl.InternetURL =
> "http://MyMachineName.domain.com/SqlRepl/sqlcesa20.dll"
> My question or problem is this...what happens in the case of a failover?
We
> have a backup/redundant/mirrored server at a different geographic
> location...obviously it has a different server name. For the devices in
the
> field, how do people handle this type of situation where the server
failover
> will occur automatically. Or, if we decide to move to a server
farm...where
> we have multiple Sql Servers...how can we make our mobile application
> agnostic to the Publisher?
> Thanks for any help or advice.
> - will
|||Would that mean the Publisher and Distributor would be on different machines?
"Hilary Cotter" wrote:

> The best way to do this is to put your publisher on a cluster.
> --
>
|||dw wrote:
> Hello...
> Currently we have merge replication set up between SQL 2000 and mobile
> devices running SQL CE 2.0...and some with SQL Mobile.
> As part of the logic on the device, we have to set some properties for the
> SqlCeReplication object. Some of these we make dynamic, like the
> publication, login, etc.
> However, we currently hard code the Publisher and InternetURL values to our
> existing server like:
> repl.Publisher = "MyMachineName"
> repl.InternetURL =
> "http://MyMachineName.domain.com/SqlRepl/sqlcesa20.dll"
> My question or problem is this...what happens in the case of a failover? We
> have a backup/redundant/mirrored server at a different geographic
> location...obviously it has a different server name. For the devices in the
> field, how do people handle this type of situation where the server failover
> will occur automatically. Or, if we decide to move to a server farm...where
> we have multiple Sql Servers...how can we make our mobile application
> agnostic to the Publisher?
> Thanks for any help or advice.
> - will
Try using a DNS alias name and have your subscribers connect to that. When you change the server,
also change DNS to point to the new machine. Will be transparent to the subscribers. Make sure
that the server will respond to the alias name.
We use aliases at my company. Recently, the motherboard on our production server died. All the
data files are on an external disk array. We have an identical server as backup. We moved the C:
hard drive to the backup server and moved the cable from the disk array. We changed DNS to point
the alias to the new server. Back up in 10 minutes.
This also works when upgrading to a bigger server.
|||No, they should be on the same machine.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"dw" <dw@.discussions.microsoft.com> wrote in message
news:09D18E34-DC6F-4EAE-82F4-07645EE1578E@.microsoft.com...
> Would that mean the Publisher and Distributor would be on different
machines?[vbcol=seagreen]
> "Hilary Cotter" wrote:

how to set default value for datetime column in sql mobile?

I try to set a default value (getdate()) for a datetime culomn in sql mobile,
but got error when i insert record:

there was a syntax error in the date format. [expression = getdate()]

may be I can only set a exict date ?

I can repro the failure you are seeing. On Searching BOL for sql mobile, It says the following about the default definitions for columns.

DEFAULT Definitions

A column can have only one DEFAULT definition. This can contain constant values or constant functions.

You should post this to the SQL Server Everywhere/Mobile/CE Edition Technical Discussion forum.