xSQL Schema Compare SDK version 9.5 for SQL Server
CreateFromSnapshot(String,EventHandler<SnapshotOperationEventArgs>) Method
Example 


The snapshot filename.
A method that should be attached to the snapshot event in order to get progress information.
Creates a database objects from the specified snapshot.
Syntax
'Declaration
 
Public Overloads Shared Function CreateFromSnapshot( _
   ByVal fileName As System.String, _
   Optional ByVal snapshotOperationProgress As System.EventHandler(Of SnapshotOperationEventArgs) _
) As SqlDatabase
public static SqlDatabase CreateFromSnapshot( 
   System.string fileName,
   System.EventHandler<SnapshotOperationEventArgs> snapshotOperationProgress
)
public: static SqlDatabase* CreateFromSnapshot( 
   System.string* fileName,
   System.EventHandler<SnapshotOperationEventArgs*>* snapshotOperationProgress
) 

Parameters

fileName
The snapshot filename.
snapshotOperationProgress
A method that should be attached to the snapshot event in order to get progress information.

Return Value

A SqlDatabase object.
Remarks
This method creates a database object and loads its entire schema from the snapshot. The newly created database behaves like any other database created from live sources.
Example
The following example demonstrates how to load the database from a snapshot:
using xSQL.Schema.Core;
using xSQL.Schema.SqlServer;
using xSQL.SchemaCompare.SqlServer;
            
namespace xSQL.Sdk.SchemaCompare.Samples
{
    class Test
    {
        public static void CreateDatabaseFromSnapshot()
        {
            SqlDatabase database;
            SqlTable table;
            ScriptingOptions options;
            
            try
            {
                //--create the database object from the snapshot file
                database = SqlDatabase.CreateFromSnapshot(@"C:\AdventureWorks.snpx");
                
                //--locate and script the Employee table
                table = database.SqlTables["HumanResources", "Employee"];
                if (table != null)
                {
                    options = new ScriptingOptions();
                    options.CreateScript = true;
                    options.DropScript = false;
                    options.AlterScript = false;
                    
                    Console.Write(table.GetScript(options));
                }
                
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

SqlDatabase Class
SqlDatabase Members
Overload List

 

 


┬ęCopyright 2018 xSQL Software. All Rights Reserved.

Send Feedback