locked
Bug - Transaction - Odbc RRS feed

  • Question

  • I want to report a bug. Don't know where to report.

    So i post it here.

     

    I started to write a SyncProvider for Odbc. I user DbServerSyncProvider like to do all the work like in the Example 'Writing a SqlServer Client SyncProvider'. Everything worked fine until i wanted to update via the Odbc Connection. The UpdateConflict Command told me:

    "ExecuteReader requires a valid Transaction....' bla bla

     

    What's wrong?

     

    I dissassembled the Microsoft.Synchronization.Data.Server.

    Class: DbServerSyncProvider

    Method: ExecuteSelectCommand

     

    Aha! There are a few lines of Code in this Method.

     

    ....

    this.SetSessionParameters(cmd, groupMetadata, tableMetadata, syncSession, columns, stage);

    cmd.Transaction = transaction;

    cmd.Connection = this._serverConnection;

    dataReader = cmd.ExecuteReader();

    ....

     

    This works well with SqlCommand. With OdbCommand you have to Change the tow lines. First assign Connection, then Transaction.

     

     

    ....

    this.SetSessionParameters(cmd, groupMetadata, tableMetadata, syncSession, columns, stage);

    cmd.Connection = this._serverConnection;

    cmd.Transaction = transaction;

    dataReader = cmd.ExecuteReader();

    ....

     

    Unfortuatly there's no workaround - and no SyncProvider for Odbc for me.

     

     

    Thursday, January 22, 2009 1:38 PM

Answers

All replies

  • Thanks Hans for reporting this issue. we will look into it and see how we can address this.

     

    thanks

    Yunwen

    Sunday, January 25, 2009 6:59 AM
    Moderator
  • Hans,

     

    The server provider was not inteded to sync using ODBC.  You may want to look at the following how-to in an effort to understand how you might go about implementing your own provider. 

     

    http://msdn.microsoft.com/en-us/library/bb902826.aspx

     

    What is motivating you to do this?

     

    Thanks

     

    Sean Kelley

     

    Sunday, January 25, 2009 8:51 AM
    Moderator
  • Hello Sean,

     

    first of all thanks for your reply.

     

    I wanted to aviod the effort to write a new provider. I thought there is a way to use existing logic.

    I think it is a very complicate task to develop a new provider.

    Is there an existing provider template or a good sample that can sync two tables from a database that I can change a little bit an use in my application?

     

     

    Our motivation to use Odbc was to sync an AS400 iSeries Db2 Database. There are some Ado Providers available for this database.

    First we tried to use the Odbc driver because other Applications in the company work with it. We stuck on the problem i decribed before.

    After that we tried to use the native Ado.Net Provider from IBM. Same Problem.

     

    I assume that the Sql Server Driver from Microsoft and the Oracle Driver from Microsoft ignore the assignment of the connection after the transaction. Maye the look if it's the same connection and if it's the same the use the existing transaction.

    Other providers - like the AS400 drivers - are not that intelligent. The rule that's used is: Assignment of connection means the the client has to begin a new transaction.

     

    So from my point of view it's allways the better way to assign first the connection and after that the transaction.

     

     

    Thaks Kelley
    Monday, January 26, 2009 8:03 AM