Options

Do I have the right tool.

FredMorinFredMorin Posts: 9
Here is what my situation is...

I have an master application that uses sql server as it's back-end.

I was successfully able today to generate a upgrade script with the samples of Comparaison SDK no sweat.

I then want to put that file on a ftp server somewhere. Again no sweat.

Now on the client side, there will be an app I wrote which will use the database as well, but locally this time... Therefore, whenever they logon I will check to see if there is a update file on the ftp, no problems....if there is I want to download it and then silently execute it...

So my question is this... is there an easy was to get the EXE generated by the SDK to silently run....

thanks

Comments

  • Options
    Hi there,

    Many thanks for your post.

    Depending on how you are getting the .EXE to run, you can do this through the command line by specifying the following:
    Applicationname.exe /quiet /server:XXX /database:XXX /username:XXX /password:XXX
    

    Does this answer your question?

    Pete
    Peter Peart
    Red Gate Software Ltd
    +44 (0)870 160 0037 ext. 8569
    1 866 RED GATE ext. 8569
  • Options
    Is there another switch needed to specify if i want to create a database or upgrade an existing one...
  • Options
    Hi there,

    The /quiet switch just forces the .EXE to be run from the command line without a GUI popping up at all.

    I would have thought that if you were creating a new DB or creating an upgrade, that would have all been built into the .EXE, therefore there isn't a need for any additional switches.

    Pete
    Peter Peart
    Red Gate Software Ltd
    +44 (0)870 160 0037 ext. 8569
    1 866 RED GATE ext. 8569
  • Options
    Thanks for the quick reply...

    I am very green as far as the SQL packagerCode Snippets goes.

    I know after running the sample I was able to create the EXE but when I would manually run it, I was given the option to Create a New DB or Upgrade.

    Is there something I missed in those samples
  • Options
    Hi there,

    If you wanted to create a database from scratch, then you would use the following:
    Applicationname.exe /quiet /server:XXX /database:<DBNameToBeCreated> /username:XXX /password:XXX
    

    If you were running an executable that upgraded a DB, the syntax would be:
    Applicationname.exe /quiet /server:XXX /rundatabase:<DBNameToBeUpgraded> /username:XXX /password:XXX
    

    A full list of command line switches available can be found if you run the following from the command line:
    sqlpackager /? /V /html > %FileOutputPath.htm%
    

    Hope that helps!

    Pete
    Peter Peart
    Red Gate Software Ltd
    +44 (0)870 160 0037 ext. 8569
    1 866 RED GATE ext. 8569
  • Options
    Thanks...

    I just realized that I have more to do that I thought.


    I figured out using the SQLDATACompareCodeSnippets and the SQL ProviderExample will synchronize the data on the second database quite easily.

    However, what I want to is create a package with the block so I can send that package on a FTP server and then my clients will retrieve that at their convenience and update.

    I figured it out...

    Since I use a second database locally which is a copy of the clients database.... i have to create the package and update the second database.. so i need to execute the block AND package it

    Dim executor As New BlockExecutor()
    executor.ExecuteBlock(provider.Block, serverName, LiveDatabaseName)


    This updates the local destination database

    AND

    Using engine As PackagerEngine = New PackagerEngine(TemplateFolder, TargetPackageFolder, PackageName, m_SchemaBlock, m_DataBlock, OutputType.Executable)

    '
    ' Add properties for the package
    '
    AddPackagerProperties(engine, serverName, databaseName, schemaOptions, dataOptions)

    Console.WriteLine("Packaging the blocks into the target executable")
    RaiseEvent SomethingHappened("Packaging the blocks into the target executable", Nothing)

    engine.Package()

    Console.WriteLine("Packaged database '{0}' on server '{1}'", databaseName, serverName)
    Dim s As String = String.Format("Packaged database '{0}' on server '{1}'", databaseName, serverName)

    RaiseEvent SomethingHappened(s, Nothing)
    s = String.Format("Generated program '{0}'", TargetFullFileName)
    Console.WriteLine(s)
    RaiseEvent SomethingHappened(s, Nothing)
    End Using

    packages the whole thing quite nicely

    I also created a table to specify which tables are to be updated.

    I therefore filter my tablemappings in my SetDataExecutionBlock

    For Each tm As TableMapping In TableMappings
    If DataRepository.SyncroTablesProvider.GetByCode(tm.Obj1.Name).Syncroniser = True Then
    tm.Include = True
    Else
    tm.Include = False
    End If
    Next

    And do the same in the SetSchemaExecutionBlock
  • Options
    Hi there,

    I am glad that you managed to get this working for you. If you need any further help, just let us know.

    Pete
    Peter Peart
    Red Gate Software Ltd
    +44 (0)870 160 0037 ext. 8569
    1 866 RED GATE ext. 8569
Sign In or Register to comment.