xSQL.Schema.SqlServer Namespace > SqlDatabase Class > SaveToSnapshot Method : SaveToSnapshot(String) Method |
'Declaration Public Overloads Sub SaveToSnapshot( _ ByVal fileName As System.String _ )
public void SaveToSnapshot( System.string fileName )
public: void SaveToSnapshot( System.string* fileName )
using xSQL.Schema.Core; using xSQL.Schema.SqlServer; using xSQL.SchemaCompare.SqlServer; namespace xSQL.Sdk.SchemaCompare.Samples { class Test { public static void SaveDatabaseToSnapshot() { SqlServer server; SqlDatabase database; try { //--create the SQL Server object, connect using Windows authentication server = new SqlServer(@"(local)"); //--create the database object database = server.GetDatabase("AdventureWorks"); //--attach an handler to SchemaOperation event in order to get progress information during the schema read database.SchemaOperation += new EventHandler<SchemaOperationEventArgs>(database_SchemaOperation); //--attach an handler to SnapshotOperation event to get snapshot feedback database.SnapshotOperation += new EventHandler<SnapshotOperationEventArgs>(database_SnapshotOperation); //--read the database schema database.ReadSchema(); //--create the snapshot database.SaveToSnapshot(Path.Combine(@"C:\", database.GetDefaultSnapshotFilename())); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } private static void database_SchemaOperation(object sender, SchemaOperationEventArgs e) { //--exclude verbose messages if (e.Message.MessageType != OperationMessageTypeEnum.Verbose) Console.WriteLine(e.Message.Text); } private static void database_SnapshotOperation(object sender, SnapshotOperationEventArgs e) { //--exclude verbose messages if (e.Message.MessageType != OperationMessageTypeEnum.Verbose) Console.WriteLine(e.Message.Text); } } }
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