cancel
Showing results for 
Search instead for 
Did you mean: 

[Mobilink] How to create the database programmattically instead of copying it manually to the device

Former Member
3,070

I'm trying to use Mobilink 12 to sync between SQL Server 2005 Database (as consolidated database) and a remote ultralite database on a windows mobile device, so i've done the following :

  1. Created a new mobilink project having the Sql Server 2005 odbc connection as a consolidated database
  2. Created a new sync model assigned the consolidated db to it -> choosed tables to include in the sync model -> created a publication "test" and a version "test
  3. Deploy the sync model -> i choose "new ultralite database" as the type of the remote database -> i check the option of "Create a remote ultralite database"

Now I copy the created ultralite db to my windows mobile device ,run the mobilink server and start writing the client test application as the following:

  1. I create a new windows mobile project and I write the following in the form load

    String ConnString = "dbf=\\Program Files\\smartdeviceproject1\\test.udb";

    Conn = new ULConnection(ConnString);

    Conn.Open();

    Conn.DatabaseID = 1;

  2. I added a button for the sync process to the form and added the following code to the button click event:

    Conn.SyncParms.Publications = "test";

    Conn.SyncParms.StreamParms = "";

    Conn.SyncParms.UserName = "test";

    Conn.SyncParms.Password = "test";

    Conn.SyncParms.Version = "test";

    Conn.SyncParms.Stream = ULStreamType.TCPIP;

    Conn.Synchronize();

And it's running perfectly , my question is Is there anyway to create the database programmatically instead of copying it manually to the device?

Accepted Solutions (1)

Accepted Solutions (1)

chris_keating
Product and Topic Expert
Product and Topic Expert

You will need to start the ML server with the -ftr switch which points to the location where the transfer files can be found. You can also have different files for different users by setting up unique folders.

A simple implementation in UL.Net is

    ULFileTransfer transfer = new ULFileTransfer();
    transfer.UserName = "u";
    transfer.Version = "v";
    transfer.Stream = ULStreamType.TCPIP;
    transfer.FileName = "MLFileTransfer.udb";
    transfer.LocalFileName = "MLFileTransferReceived.udb";
    string[] parms = new string[1];
    parms[0] = "You need to supply something";
    transfer.AuthenticationParms = parms;

    transfer.DownloadFile();
    transfer = null;
    System.Console.WriteLine("File transfer complete. ");

Answers (1)

Answers (1)

chris_keating
Product and Topic Expert
Product and Topic Expert

Look at ULDatabaseManager CreateDatabase() method to create the database. You can couple this with ULFileTransfer to transfer the schema to the remote and use "ALTER DATABASE SCHEMA FROM FILE" to create the schema in the remote. Another option is push the database to the remote using ULFileTransfer to automate the process.

Former Member
0 Kudos

Seems to be a good solution ,but i've searched for any samples of how to use ULFiletransfer to download a file and I couldn't find anyone ,so it would be great if you could provide any sample for that