new to sync. best practice to enable established app to use sync? RRS feed

  • Question

  • hi all,

    i just got sync working in my vb.net app.  it is a basic equipment management system.  i have a local db now setup, the localdatacache.sync is in the project, and i added all of my tables, and it created a brand-new dataset in my application.

    in my original dataset, i had all the tables i use for the app...a complete project dataset (of about 20 tables).  this dataset had a lot of extra queries for loading one "equipment" based on ID, as does many other tableadapters.

    I assume it is not as easy as changing the connection property on all of the tableadapters in my existing dataset to use the local connection created with the "Configure Data Synchronization" dialog?  If not, would this mean that i need to change all of my bindings on all of my forms to use this new dataset that was generated?


    Monday, September 17, 2012 9:38 PM

All replies

  • just change the connection string. not unless, you've changed the structure of your tables.
    Tuesday, September 18, 2012 1:31 AM
  • i'm thinking it may be a little harder than that.   I have some stored procedures that help fill in data in one of my main listing screens...i gotta re-write that one i guess. 

    Also, when previewing my data in the dataset, i now get the error : "No mapping exists from DbType AnsiString to a known SQL Server Compact data type".   All the parameters from the original datasource inserts, updates are all of type Ansistring...yikes.  I did a global replace on AnsiString in the dataset designer file, and so far so good.

    all of this works great now, but i still have one nagging thing....

    It would be great if there was an easy way to cycle through my form's table adapters and set that connectionstring.  As it stands, i have to set each one individually on form_load if i am working locally.  Is there an easy way to cycle through the table adapters to do this?  Would be nice to just call a function and pass the form in.



    • Edited by Ge0rg3 Tuesday, September 18, 2012 5:53 PM
    Tuesday, September 18, 2012 5:10 PM
  • some quick reading shows me now that sql compact 3.5 doesn't support varchars...only nvarchar. apparently, sqlce only likes unicode.  d'oh. 

    Im going back through my sqlserver database and switching all of these to nvarchar() now and chage out all the references to AnsiString and substitute with a "string".

    now of course, i'll keep testing debugging and re-coding until i have two modes for this app...connected and work locally.

    whew...i'll be proud papa when this all works.


    Tuesday, September 18, 2012 6:24 PM
  • having trouble with this connection string thing....

    so i made sure to have the right versions of everything.  in my app if a flag is set "worklocal" then i change the connection property and connectionstring property in my data access class.

    when i open a form that needs to load data, i do this (gData is my data class):

                If gData.WorkLocally Then
                    CheckEdit1.Checked = gData.WorkLocally
                    LocationsTableAdapter.Connection.ConnectionString = My.Settings.ClientConnectionString
                End If

    so if i leave the default to the connectionstring generated when i added the localdatacache, it tells me:

    "Keyword not supported: 'max database size'."

    if i remove that part from the connectionstring, it tells me the following after hanging for several seconds:

    "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

    Im screwed if i do, and screwed if i dont.  Not sure what to do now.  Im not so sure it is as easy as just swapping out a connectionstring.....

    any help is greatly appreciated!!!!


    • Edited by Ge0rg3 Wednesday, September 19, 2012 8:37 PM
    Wednesday, September 19, 2012 8:31 PM
  • cant just swap out the connectionstring....everyting embedded in the "live" dataset uses system.data.sqlclient (sqlconnection, sqldataadapter, sqlparameter)...all of this is embedded in the dataset designer file, so swapping out a connection string will make the sqlclient freak out with a file path and max database size paramters in the connectionstring.

    so at this point, the only way i figure i can have a "live mode" and a "disconnected mode" is to have two datasets in the app with identical queries in the table adapters, and change the bindings on the forms out at runtime. This also means having two table adapters per table and using one or the other depending on the connection type.

    The other option I guess is to always work locally, and sync on startup and exit of the app.

    If im missing a "one wierd trick" to having two modes with very little modification to my app please let me know, cause i'm stumped.


    Wednesday, September 19, 2012 10:51 PM