cancel
Showing results for 
Search instead for 
Did you mean: 

Where can I find UltraLite.NET sample code showing MobiLink synchronization?

Breck_Carter
Participant
0 Kudos
12,701

...the title says it all.

Accepted Solutions (2)

Accepted Solutions (2)

regdomaratzki
Product and Topic Expert
Product and Topic Expert

Here's a sample I'd cooked up some time ago on my machine.

using System;
using System.Collections.Generic;
using System.Text;
using iAnywhere.Data.UltraLite;

namespace simple
{
  class Program
  {
    static void Main(string[] args)
    {
      ULConnection Conn;

try {
        ULDatabaseManager.RuntimeType = ULRuntimeType.STANDALONE_UL;
        String ConnString = "dbf="+ args[0] + "\\\\" + args[0] + ".udb";
        Conn = new ULConnection( ConnString );
        Conn.Open();
        Conn.SyncParms.Version = "v1";
        Conn.SyncParms.UserName = args[0];
        Conn.SyncParms.Password = "sql";
        Conn.SyncParms.Stream = ULStreamType.TCPIP;
        Conn.SyncParms.StreamParms = "host=localhost";
        Conn.Synchronize();
        Console.WriteLine( "SyncResults" );
        Console.WriteLine( "== AuthStatus is " + Conn.SyncResult.AuthStatus );
        Console.WriteLine( "== AuthValue is " + Conn.SyncResult.AuthValue  );
        Console.WriteLine( "== IgnoredRows is " + Conn.SyncResult.AuthValue );
        Console.WriteLine( "== PartialDownloadRetained is " + Conn.SyncResult.PartialDownloadRetained );
        Console.WriteLine( "== StreamErrorCode is " + Conn.SyncResult.StreamErrorCode );
        Console.WriteLine( "== StreamErrorContext is " + Conn.SyncResult.StreamErrorContext );
        Console.WriteLine( "== StreamErrorID is " + Conn.SyncResult.StreamErrorID );
        Console.WriteLine( "== StreamErrorSystem is " + Conn.SyncResult.StreamErrorSystem );
        Console.WriteLine( "== Timestamp is " + Conn.SyncResult.Timestamp );
        Console.WriteLine( "== UploadOK is " + Conn.SyncResult.UploadOK );
        Conn.Close();
      } catch ( Exception t ) {
        Console.WriteLine( "Exception: " + t.ToString());
      }

}
  }
}

Just create a file named simple.cs with the code above in it, and then complile it with something similar to :

csc /platform:x86 /debug /out:simple.exe /target:exe /reference:"%SQLANY12%\\ultralite\\ultralite.net\\assembly\\v2\\iAnywhere.Data.UltraLite.dll" simple.cs
Breck_Carter
Participant
0 Kudos

Woohoo! I can move The Big Green Arrow!

regdomaratzki
Product and Topic Expert
Product and Topic Expert

I think real .NET programmers might actually verify the args[0] parameter before passing it into a ConnString, and would likely break up the code into multiple try/catch blocks, but this sample does show setting up SyncParms in the ULConnection object and then making use of the SyncResult object to check results. I'll leave "making it pretty" as an exercise for the student. 🙂

Former Member

If you want an application along with the full source code, have a look at the AdventureWorks Windows Mobile samples here:

http://www.sybase.com/detail?id=1065480

It contains an UL.NET sample and you can see some of the code right on that web page. You can also download the complete Visual Studio project.

José

Breck_Carter
Participant
0 Kudos

That sample uses cmd.CommandText = "SYNCHRONIZE PROFILE SalesMobile"; instead of conn.Synchronize(); and it makes no reference to SyncParms.

Answers (1)

Answers (1)

Former Member
0 Kudos

Documentation:


private void Sync()
{
    // Sync
    try
    {
         // setup to synchronize a publication named "high_priority"
         conn.SyncParms.Publications = "high_priority";

// Set the synchronization parameters 
         conn.SyncParms.Version     = "Version1";
         conn.SyncParms.StreamParms = "";
         conn.SyncParms.Stream      = ULStreamType.TCPIP;
         conn.SyncParms.UserName    = "51";
         conn.Synchronize();
    }     
    catch (System.Exception t)
         {
           MessageBox.Show("Exception: " + t.Message);
         }
}

More: http://dcx.sybase.com/index.html#1200en/uldotnet/uljavadotnet-development-s-5339942.html

Breck_Carter
Participant

That Help topic comes with no supporting explanation... plus, conn.SyncParms.StreamParms = ""; really should be "host=..." in order to be useful.

regdomaratzki
Product and Topic Expert
Product and Topic Expert

Not a big fan of this sample either, since there's no context for the conn object. I know it's a ULConnection object, but there's no way to see that in the sample. I've added a comment on DCX to at least change the method signature to "private void Sync( ULConnection conn )"