J
Jeff
Hi -
I'm have a VB.NET Windows application that uses an MSDE database. I'm
trying to code backup, restore, and checkdb/repair functions.
Before each of these operations, I change the connection database to
"master" and then execute an "ALTER DATABASE SC01 SET SINGLE_USER"
statement. Very occasionally, this progression works fine. But most of the
time, I get a Timeout expired error on the set single-user command. I've
tried setting commandtimeout to 60, and I get the same result (it just takes
longer).
What am I doing wrong, and/or how can I get these functions to work
correctly and reliably??
My database name is 'SC01'. The connection string for conSCdata is "packet
size=4096;user id=sa;data source="(local)\InstName";persist security
info=True;initial catalog=SC01;password=SPassword" (and the connection is
open). I have already created SCBackupDevice using sp_addumpdevice.
Here's my code for the backup operation:
frmMain.conSCdata.ChangeDatabase("master")
strSQL = "ALTER DATABASE SC01 SET SINGLE_USER"
SQLcmd = New SqlCommand(strSQL, frmMain.conSCdata)
SQLcmd.ExecuteNonQuery()
SQLcmd = Nothing
strSQL = "BACKUP DATABASE SC01 TO SCBackupDevice"
SQLcmd = New SqlCommand(strSQL, frmMain.conSCdata)
SQLcmd.ExecuteNonQuery()
SQLcmd = Nothing
strSQL = "ALTER DATABASE SC01 SET MULTI_USER"
SQLcmd = New SqlCommand(strSQL, frmMain.conSCdata)
SQLcmd.ExecuteNonQuery()
SQLcmd = Nothing
frmMain.conSCdata.ChangeDatabase("SC01")
Thanks for your help.
- Jeff
I'm have a VB.NET Windows application that uses an MSDE database. I'm
trying to code backup, restore, and checkdb/repair functions.
Before each of these operations, I change the connection database to
"master" and then execute an "ALTER DATABASE SC01 SET SINGLE_USER"
statement. Very occasionally, this progression works fine. But most of the
time, I get a Timeout expired error on the set single-user command. I've
tried setting commandtimeout to 60, and I get the same result (it just takes
longer).
What am I doing wrong, and/or how can I get these functions to work
correctly and reliably??
My database name is 'SC01'. The connection string for conSCdata is "packet
size=4096;user id=sa;data source="(local)\InstName";persist security
info=True;initial catalog=SC01;password=SPassword" (and the connection is
open). I have already created SCBackupDevice using sp_addumpdevice.
Here's my code for the backup operation:
frmMain.conSCdata.ChangeDatabase("master")
strSQL = "ALTER DATABASE SC01 SET SINGLE_USER"
SQLcmd = New SqlCommand(strSQL, frmMain.conSCdata)
SQLcmd.ExecuteNonQuery()
SQLcmd = Nothing
strSQL = "BACKUP DATABASE SC01 TO SCBackupDevice"
SQLcmd = New SqlCommand(strSQL, frmMain.conSCdata)
SQLcmd.ExecuteNonQuery()
SQLcmd = Nothing
strSQL = "ALTER DATABASE SC01 SET MULTI_USER"
SQLcmd = New SqlCommand(strSQL, frmMain.conSCdata)
SQLcmd.ExecuteNonQuery()
SQLcmd = Nothing
frmMain.conSCdata.ChangeDatabase("SC01")
Thanks for your help.
- Jeff