Home All Groups Group Topic Archive Search About
Author
20 Feb 2006 5:31 PM
DavideR
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

Author
21 Feb 2006 12:07 PM
Ken Tucker [MVP]
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
-------------------
Show quoteHide quote
"DavideR" <Davi***@discussions.microsoft.com> wrote in message
news:634945EE-34B8-49E5-8C6E-6F8202EF0B95@microsoft.com...
> 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
>
Author
21 Feb 2006 3:40 PM
DavideR
i tried but the problem reamins
how can i drop via  the connection???

Show quoteHide quote
"Ken Tucker [MVP]" wrote:

> 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
> -------------------
> "DavideR" <Davi***@discussions.microsoft.com> wrote in message
> news:634945EE-34B8-49E5-8C6E-6F8202EF0B95@microsoft.com...
> > 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
> >
>
>
>
Author
26 Mar 2006 10:52 PM
Ruud Ortmans
Davide,

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


Show quoteHide quote
"DavideR" wrote:

> i tried but the problem reamins
> how can i drop via  the connection???
>
> "Ken Tucker [MVP]" wrote:
>
> > 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
> > -------------------
> > "DavideR" <Davi***@discussions.microsoft.com> wrote in message
> > news:634945EE-34B8-49E5-8C6E-6F8202EF0B95@microsoft.com...
> > > 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
> > >
> >
> >
> >