on 2010 Sep 10 1:24 PM
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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. 🙂
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é
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That Help topic comes with no supporting explanation... plus, conn.SyncParms.StreamParms = ""; really should be "host=..." in order to be useful.
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 )"
User | Count |
---|---|
68 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.