473,769 Members | 2,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.connectio n
dim rs as new adodb.connectio n
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 2288
Hi,

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

Imports Microsoft.SqlSe rver.Management .Smo

Module Module1

Sub Main()
Dim svr As Server = New Server(".\SQLEX PRESS")
svr.DetachDatab ase("Northwind" , True)

End Sub

End Module
Ken
-------------------
"DavideR" <Da*****@discus sions.microsoft .com> wrote in message
news:63******** *************** ***********@mic rosoft.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.connectio n
dim rs as new adodb.connectio n
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.sqlse rver.smo

Imports Microsoft.SqlSe rver.Management .Smo

Module Module1

Sub Main()
Dim svr As Server = New Server(".\SQLEX PRESS")
svr.DetachDatab ase("Northwind" , True)

End Sub

End Module
Ken
-------------------
"DavideR" <Da*****@discus sions.microsoft .com> wrote in message
news:63******** *************** ***********@mic rosoft.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.connectio n
dim rs as new adodb.connectio n
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.KillAllProc esses() 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.sqlse rver.smo

Imports Microsoft.SqlSe rver.Management .Smo

Module Module1

Sub Main()
Dim svr As Server = New Server(".\SQLEX PRESS")
svr.DetachDatab ase("Northwind" , True)

End Sub

End Module
Ken
-------------------
"DavideR" <Da*****@discus sions.microsoft .com> wrote in message
news:63******** *************** ***********@mic rosoft.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.connectio n
dim rs as new adodb.connectio n
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
373
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 datareader and cannot access the datareader once the connection is closed. Here is what I do: public function getDataReader() as datareader
3
9114
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 the client machine to close per my network app the computer fills up w/ thousands of these :0 TCP foobox:8888 localhost:2188 TIME_WAIT :0 TCP foobox:8888 localhost:2189 TIME_WAIT :0 TCP foobox:8888 localhost:2190 TIME_WAIT
2
2279
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 connection that you close it with: adoCon.Close Set adoCon = Nothing
8
2161
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 up our connections. We did so by encapsulating with the using statement. Ex: using (SqlConnection myConnection = new SqlConnectionConfigurationSettings.AppSettings))
6
10987
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 { myDataAdapter.Fill(myDataTable);
35
11421
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 Then CType(cn, IDisposable).Dispose() End If I have to admit, I'm not sure what happens here. Will someone explain this line of code (the middle one, not the if statement LOL) to me please?
17
2384
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, this method doesn't close it, it just returns the datareader. The calling code uses the datareader and then just lets it drop out of scope, to be picked up by the garbage collector. Is this a problem? A friend of mine suggested to me that not...
8
9637
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 work from
6
16788
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 = new OracleConnection(this.ConnectionString); this.Connection.Open();
4
3433
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 server. Issue a command or two, then close the connection. My question is, wouldn't it be better to have One connection open during the current session and when the session end, close the connection.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.