Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 SMO fails on one not another

Author  Topic 

lufueury
Starting Member

1 Post

Posted - 2006-06-09 : 09:50:24
Can anyone enlighten me on using smo backup with sqlexpress?
I have compiled an exe using vbc running the folloing code
Imports System
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common
Imports System.IO

Module SMOtest
Sub Main()
Try
Kill(System.Environment.GetFolderPath Environment.SpecialFolder.ProgramFiles) & "\test\SMO_BACKUP")
Catch
End Try
Try
System.Threading.Thread.Sleep(500)
Dim bkpfileName As String = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\test\SMO_BACKUP"
Dim backDeviceItem As New BackupDeviceItem(bkpfileName, DeviceType.File)
Dim db As String = "test" ' Define and set db
Dim bck As New Backup() ' Instantiate a Backup object
bck.Action = BackupActionType.Database ' Set Action
bck.BackupSetName = db & "_BackupSet" ' Set Backup
bck.Database = db ' Set Database name property
bck.Devices.Add(backDeviceItem)
Dim srv As New Server() ' Instantiate a Server object
bck.SqlBackup(srv) ' Invoke Backup object's SqlBackup method
Catch
End Try
End Sub
End Module

This works fine on a win2k dev system though when moving to another win2k system the code will error on non system databases. If db= model,master,tempdb etc it executes fine. When I try to backup a created db (any) I get an error stating the name is not found in sysdatabases.

SELECT name FROM master..sysdatabases
where name not in ('master','tempdb')

shows all the created databases including "test" in this case
keep in mind many recompiles using different db's work fine on one system and not the other. Even restored "test" from a backup from the system with no problems only to have a 3041 error consistently on the other. System databases work fine for all attempts on the offending system.
Any ideas? (the offending system is a SAT raid which has been evil from the get go) corruption seems to be the only conclusion I can reach
   

- Advertisement -