473,385 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

close connection

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

Feb 20 '06 #1
3 2267
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" <Da*****@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.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

Feb 21 '06 #2
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" <Da*****@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.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


Feb 21 '06 #3
Davide,

A bit late.
Use srv.KillAllProcesses() before you detach with SMO.
For me it works.
"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" <Da*****@discussions.microsoft.com> wrote in message
news:63**********************************@microsof t.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


Mar 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: sam | last post by:
Hello group, I have a function which is used to initiate sqlDataReader object. I was trying to invoke the close method on the DataReader object but cant really do that as the function returns a...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
2
by: InvisibleMan | last post by:
Hi, I feel a little dumb for asking this (considering im writing TSQL) but there doesn't seem to be any definitive answers on the search engines... Okay I understand that if you open the ADO...
8
by: Pierson C | last post by:
I am developing on a website that is utilizing SQL Server 2000. Shortly after deploying the site, we began having timeout issues due to the max connections. 1st instinct was to diligently tidy...
6
by: M | last post by:
Hi, Does SqlDataAdapter always close the connection (assuming connection was closed before calling Fill()), even if an exception occurs while calling Fill()? Example: try {...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
17
by: Alan Silver | last post by:
Hello, I have a generic method in a utility class that grabs an sqldatareader and returns it. Due to the fact that (AFAIK), you can't close the database connection before you've read the data,...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
6
by: S_K | last post by:
Hi all! I'm writing an ASP.NET web application that uses an Oracle database. I OPEN the Oracle connection by using the following code: if (this.ConnectionString != "") { this.Connection =...
4
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I am currently developing my first webapplication using .net (2.x) In a couple examples seen in the helpfile that came with VS2008 i see that they are opening a connection to the sql...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.