When I need to execute a backup-script, I close the user-connection
and reopen the database with an admin-connection to allow the stored
procedure to execute.
This works, but when after that I re-open the user-connection, the
state is 1 (=open), but at the first ' Dim sqlCmd As New
SqlCommand(sql, CONN) sqlCmd.ExecuteScalar' I get the error 'no
proceess at the other end' and in fact the connection (CONN) closes.
I tried with/without the CONN.dispose and/or CONN = New
SqlConnection(UserConnectionString), but always the same result.
True, other stations may still have some handle on the database, so me
closing is maybe not enough, but that is an issue that I will tackle
later.
CONN.Close() 'can't restore if still open
CONN.Dispose()
Using sc As New SqlConnection(AdminConnectionString)
sc.Open()
Dim CMDsc As New SqlCommand("exec [dbo].
[sp_backup_PROD_2_TEST]", sc)
CMDsc.ExecuteNonQuery()
CMDsc.Dispose()
End Using
're-open the connection
CONN = New SqlConnection(UserConnectionString)
CONN.Open()
Regards
|