close connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm working with vs2005 (vb.net)
i need to detach a database
autoclose property is set to true
close cursor on commit is set to true
i use the sp_detach with adodb (the program has been converted from vb6)
and i receive the error that db is still in use becouse the connection is
still actibe
i still access to file via adodb
in the routine in which i read the db the code is
sub readdb
dim con as new adodb.connection
dim rs as new adodb.connection
con.open
rs.open...
....read the file
rs.close
con.close
rs = nothing
con = nothing
end sub
at the end of the sub even if i try and retry to detach db the connection
reamins active for ever while i expect not (after a while)
why?
i try to use a sqldatareader and an sqlclient but the problem remains
Is there a way to drop connections active via code?
thanks
best regards
DavideR
 
Hi,

Why don't you try to use the smo class to detach the database.
Add a reference to microsoft.sqlserver.smo

Imports Microsoft.SqlServer.Management.Smo

Module Module1

Sub Main()
Dim svr As Server = New Server(".\SQLEXPRESS")
svr.DetachDatabase("Northwind", True)

End Sub

End Module


Ken
 
Davide,

A bit late.
Use srv.KillAllProcesses() before you detach with SMO.
For me it works.
 
Back
Top