locked
Problem with DbServerSyncProvider inherited class RRS feed

  • Question

  • Hi All,

     

    I am trying to synchronize a Sql 2005 Mobile database with a Sql Server 2005 database by following the documentation from:

     

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

     

    I have created a class which inherits from DbServerSyncProvider as it shows in the samples.  I create a SqlConnection object and assign it to the Connection property, but it will not compile.  Here is the class:

     

    class vsServerSyncProvider : DbServerSyncProvider

    {

      public vsServerSyncProvider(SqlConnection ServerConnection)

      {

        this.Connection = ServerConnection;

      }

    }

     

    When I try to compile, I get these errors:

     

    Error 1 The type 'System.Data.IDbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. C:\Documents and Settings\alex\My Documents\Visual Studio 2005\Projects\DataTest\DataTest\vsServerSyncProvider.cs 15 13 DataTest

    Error 2 Cannot implicitly convert type 'System.Data.SqlClient.SqlConnection' to 'System.Data.IDbConnection' C:\Documents and Settings\alex\My Documents\Visual Studio 2005\Projects\DataTest\DataTest\vsServerSyncProvider.cs 15 31 DataTest

    I've tried to explicitly cast it to IDbConnection, but it just gives more errors, and there are no casts in the samples.  I have removed and re-added a reference for System.Data.dll, but it still gives the error.

     

    Can anyone tell me what I'm doing wrong here?

     

    Thanks,

     

    Alex

     

    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:04 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Tuesday, June 17, 2008 12:00 AM

Answers

  • Hi Alex,

     

    I suspect if your compile errors are related to the DbServerSyncProvider. If you change your class to not derived from DbServerSyncProvider, can you still see the same compile errors? If yes, you may want to check your GAC to verify if you have the correct version of System.Data installed. Otherwise, please share your full source file.

     

    Thanks,
    Dong

    Thursday, June 19, 2008 5:32 PM
    Moderator