473,396 Members | 1,743 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,396 software developers and data experts.

Close all connections to database

5
Hi all.
I'm using VB2005 with SQL Server Express Ed. When I try to copy the database file to another location I get an error message warning me that those files are still in use. Is it to possible to perform this operation??? How???
Jun 16 '07 #1
5 4277
hariharanmca
1,977 1GB
Hi all.
I'm using VB2005 with SQL Server Express Ed. When I try to copy the database file to another location I get an error message warning me that those files are still in use. Is it to possible to perform this operation??? How???
No,Only thing is you have to stop your VB2005 App. Becouse VB2005 Appi Opening the Database
Jun 16 '07 #2
bbetoo
5
You mean that only by restarting the application can I break the link to the database????
Jun 16 '07 #3
You probably need to do a couple of things.

1) In your code, you need to close your db connection. Then you need to set that connection to nothing to get rid of it. Anytime you are done with a connection it should be closed.

2) Are you moving just the database or will you include sql server 2005 express in your app? IF you are moving just the database, you will need to detach it from SQL Server 2005. Do you have Studio Management Express installed? (It's free from MS). You can detach from this. However, anywhere you want your application, you will need SQL Server and you will need to reattach it. Or you can set up your app for network use.
Jun 16 '07 #4
bbetoo
5
This is what i'm trying to due:

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
If (MsgBox("Are you sure you want to exit the application?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes) Then
SqlConnection.ClearAllPools()
Dim strcon As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=" & strcon_file & "\close.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
Dim connBD As New SqlConnection(strcon)
Dim connBD_Limits As New SqlConnection(strcon)
My.Computer.FileSystem.CopyFile(strcon_file & "\RADS_DB.mdf", strcon_network & "\RADS_DB.mdf", True)
My.Computer.FileSystem.CopyFile(strcon_file & "\RADS_DB_log.ldf", strcon_network & "\RADS_DB_log.ldf", True)
'My.Computer.FileSystem.CopyFile(strcon_file & "\reports\Anexo_C.xls", strcon_network & "\reports\Anexo_C.xls", True)
'My.Computer.FileSystem.CopyFile(strcon_file & "\reports\Anexo_D.xls", strcon_network & "\reports\Anexo_D.xls", True)
'My.Computer.FileSystem.CopyFile(strcon_file & "\reports\Anexo_E.xls", strcon_network & "\reports\Anexo_E.xls", True)
'My.Computer.FileSystem.CopyFile(strcon_file & "\help\RADS_DB - Manual de Utilização.pdf", strcon_network & "\help\RADS_DB - Manual de Utilização.pdf", True)
'My.Computer.FileSystem.CopyFile(strcon_file & "\help\PAC A34 025.pdf", strcon_network & "\help\PAC A34 025.pdf", True)
'If My.Computer.FileSystem.DirectoryExists(strcon_file & "\files") = True Then
'My.Computer.FileSystem.CopyDirectory(strcon_file & "\files", strcon_network & "\files", True)
'End If
Me.Close()
End If
End Sub
Jun 16 '07 #5
hariharanmca
1,977 1GB
You mean that only by restarting the application can I break the link to the database????

No, I mean to stop compailing your code.before that you've to be sure that all the connections opened are closed properly
Jun 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Lin Ma | last post by:
Hello, I have a general question. In my asp page, I have DB connection, Recordset, and some variables like dim name, conn, rs set conn = Server.CreateObject("ADODB.Connection") .... set rs=...
4
by: Macca | last post by:
Hi, I have an windows forms application that accesses a SQL database I have a few questions as to connecting to the database. This application will run 24 hours a day. It is a monitoring...
2
by: Michael | last post by:
Hello, In my past ASP pages, at the top I used an include file to open an ado connection for the entire page, then at the bottom, I would have another include file to close the connection. ...
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...
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...
3
by: Chris Smith | last post by:
Hi everyone, I'm running into a rather serious problem in a production application using PostgreSQL. We've got about a connection every 4 seconds being created to the database. Most of the...
10
by: coosa | last post by:
How do i close a current connection to a database using t-sql? I fail some time to drop the database getting messages that it's currently in use. Using the wizard to delete the database, i could...
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...
8
by: Imran Aziz | last post by:
Hello All, Like in C++ I tried to use constructor to open a database connection and distructor to close the database connection, it now turns out that one cannot create distrutors in C# classes. ...
3
by: Tyno Gendo | last post by:
I just wondered if someone could clarify... I have a a script connecting with mysql_connect and in an include at end of page mysql_close If they script terminates before end of page ie. with an...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.