Do I have the right tool.

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

Do I have the right tool.

Postby FredMorin » Sun Feb 21, 2010 1:15 am

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
FredMorin
 
Posts: 7
Joined: Wed Nov 26, 2008 11:21 pm

Postby peter.peart » Mon Feb 22, 2010 4:04 pm

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:

Code: Select all
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
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids

Postby FredMorin » Mon Feb 22, 2010 8:53 pm

Is there another switch needed to specify if i want to create a database or upgrade an existing one...
FredMorin
 
Posts: 7
Joined: Wed Nov 26, 2008 11:21 pm

Postby peter.peart » Mon Feb 22, 2010 9:00 pm

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
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids

Postby FredMorin » Mon Feb 22, 2010 9:55 pm

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
FredMorin
 
Posts: 7
Joined: Wed Nov 26, 2008 11:21 pm

Postby peter.peart » Tue Feb 23, 2010 11:59 am

Hi there,

If you wanted to create a database from scratch, then you would use the following:

Code: Select all
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:

Code: Select all
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:

Code: Select all
 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
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids

Postby FredMorin » Tue Feb 23, 2010 3:43 pm

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
FredMorin
 
Posts: 7
Joined: Wed Nov 26, 2008 11:21 pm

Postby peter.peart » Thu Feb 25, 2010 6:13 pm

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
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests