locked
One question when I ran the sample application “Database Sync:SQL Server and SQL Express N-Tier with WCF” . RRS feed

  • Question

  • I did not have such issue when I used the integrated connection string (Integrated Security=true) to the remote server. However, I encountered an issue when I included the user Id and password in the connection string.

    There are two methods in the class “SqlWebSyncService.cs”

            public DbSyncScopeDescription GetScopeDescription()

            {

                Log("GetSchema: {0}", this.peerProvider.Connection.ConnectionString);

              

                DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope(SyncUtils.ScopeName, (SqlConnection)this.dbProvider.Connection);

                return scopeDesc;

            }

     

            public bool NeedsScope()

            {

                Log("NeedsSchema: {0}", this.peerProvider.Connection.ConnectionString);

     

                SqlSyncScopeProvisioning prov = new SqlSyncScopeProvisioning((SqlConnection)this.peerProvider.Connection);

     

                return !prov.ScopeExists(this.peerProvider.ScopeName);

            }

     

    The first method worked correctly, but the second cut the password off, thus the user Id cannot log in to the database. It worked fine when I hardcoded a valid connection string here.

    If you have any experience with this, could you please give me some advice?

    Thanks!

    Monday, November 14, 2011 8:58 PM

Answers

  • yes, the service should be keeping its own connection string. the client should only know about the service but should not be privy to which database the service is pointing to.

     

    • Marked as answer by jz2012 Tuesday, November 15, 2011 1:30 PM
    Tuesday, November 15, 2011 1:13 PM

All replies

  • are you sure you set the connection string on the correct provider?

    your first method is using this.dbProvider.Connection, while the second one uses this.PeerProvider.Connection

    Monday, November 14, 2011 11:46 PM
  • Thanks for your inputs. I will check it when I come to office tomorrow.
    Monday, November 14, 2011 11:50 PM
  • Good morning June,

    Even I used the connection "this.dbProvider.Connection" in the second method, the method still can not work. I printed off the connection. The password in the coonection string was removed automatically. However, I do not think this is a big issue since we should store the server connection string in the server side rather then in the client side, right?

    By the way, in my another post, I asked if I need to create each scope for every individual client (I have about 50 clients). I have a scenario that some clients get database schema updated but the other may still use the old version.

    I look forward to hearing from you shortly.

    Thanks!

    Tuesday, November 15, 2011 11:53 AM
  • yes, the service should be keeping its own connection string. the client should only know about the service but should not be privy to which database the service is pointing to.

     

    • Marked as answer by jz2012 Tuesday, November 15, 2011 1:30 PM
    Tuesday, November 15, 2011 1:13 PM