...the title says it all.

asked 10 Sep '10, 12:24

Breck%20Carter's gravatar image

Breck Carter
25.7k427586845
accept rate: 20%


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
permanent link

answered 09 Nov '10, 14:25

Reg%20Domaratzki's gravatar image

Reg Domaratzki
5.2k33575
accept rate: 41%

Woohoo! I can move The Big Green Arrow!

(09 Nov '10, 14:59) Breck Carter
2

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. :)

(09 Nov '10, 15:26) Reg Domaratzki

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é

permanent link

answered 13 Sep '10, 21:23

Jos%C3%A9%20Ramos's gravatar image

José Ramos
1.0k51524
accept rate: 30%

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

(14 Sep '10, 11:39) Breck Carter

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

permanent link

answered 13 Sep '10, 19:37

Josh%20Savill's gravatar image

Josh Savill
510135
accept rate: 27%

Comment Text Removed
Comment Text Removed
2

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

(14 Sep '10, 11:49) Breck Carter
2

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 )"

(09 Nov '10, 14:24) Reg Domaratzki
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×13

question asked: 10 Sep '10, 12:24

question was seen: 1,573 times

last updated: 09 Nov '10, 14:25