Pregunta: | 41942 - CÓMO HACER UN BACKUP DE MI DB SQL 7 DESDE VB 6.0 |
Autor: | Luis Muro |
Deseo poder hacer un Backup de mi base de datos de SQL 7.0 desde Visual Basic, enviarlo a otro servidor y, desde allí restaurarlo (el otro servidor tiene también el SQL 7.0 con la base de datos ya creada, incluída las mismas tablas).
Ambos servidores están bajo la misma plataforma y tienen instalado el mismo sistema en VB 6.0, con la diferencia que el primero sólo puede enviar información y el segundo recibirla. Espero puedan ayudarme con esto. Muchas gracias. |
Respuesta: | Luis Muro |
Ya lo conseguí. Gracias de todas maneras.
Aquí la sección del código para hacerlo: Dim strBackup as String ' Create a Backup object and set action and source database properties. Dim oBackup As New SQLDMO.Backup oBackup.Action = SQLDMOBackup_Files oBackup.Database = "Northwind" ' Example illustrates backup of multiple file groups. oBackup.DatabaseFileGroups = "[PRIMARY],[NorthwindTextImg]" ' Example illustrates a striped backup using two target devices. Note: ' Device creation is not illustrated in this example. oBackup.Devices = "[NorthDev1],[NorthDev2]" ' Optional. Backup set name and description properties provide ' descriptive text when backup header is displayed for the device(s). oBackup.BackupSetName = "Northwind_FileGroups_" & Date & "_" & Time oBackup.BackupSetDescription = _ "Backup of PRIMARY and NorthwindTextImg filegroups." ' Call GenerateSQL method to generate the Transact-SQL command batch. ' The command batch returned can provide a value for the Command ' property of a JobStep object. ' Note: A connected SQLServer object is not necessary for routine ' execution. strBackup = oBackup.GenerateSQL Para esto se debe agregar a nuestro proyecto, la Referencia a: Microsoft SQLDMO Object Library (SQLDMO.RLL) Espero que a alguien le sirva. Adios. |