473,691 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Closing database in VB .Net

Hello everone.

Can somebody help me?
When I run my code I can read, write to and delete from database, but when I
have done one of these things and try to copy the databasefile from my
folder to an other folder with Windows Explorer the system "hangs up" for a
couple of minutes. It seems like the databasefile is not closed. But after
2 - 3 minutes the system recover, and I can copy the file without any system
"hangups".

This is a problem because when I try to write to or delete from the database
with my program, it seems like the program also "hangs up" and I must wait
2 - 3 minutes till it recover again. Then the changes is stored.

This is the code I use when I try to write to the database:

Dim sSQL As String

Dim connection As String

connection = "provider=Micro soft.JET.OLEDB. 4.0;Data
Source=J:\Besti lling.mdb"

sSQL = "INSERT INTO Bestillinger (StudentNummer, DatamaskinType, LeieTid)
VALUES ('" & studentNr & "', '" & typeMaskin & "', '" & leiePeriode & "')"

Dim testConn As New System.Data.Ole Db.OleDbConnect ion(connection)

Dim testCmd As New System.Data.Ole Db.OleDbCommand (sSQL, testConn)

Try

testConn.Open()

Catch myExceptions As System.Exceptio n

Console.WriteLi ne(myExceptions .Message)

End Try

Console.Write(" Test", sSQL)

Console.ReadLin e()

If testConn.State = ConnectionState .Open Then

Try

testCmd.Execute NonQuery()

Catch myExceptions As System.Exceptio n

Console.WriteLi ne(myExceptions .Message)

Console.ReadLin e()

End Try

testConn.Close( )

End If
Nov 20 '05 #1
1 1515
On Fri, 31 Oct 2003 18:43:47 +0100, "Vegar Hansen" <ve**********@b roadpark.no> wrote:

¤ Hello everone.
¤
¤ Can somebody help me?
¤ When I run my code I can read, write to and delete from database, but when I
¤ have done one of these things and try to copy the databasefile from my
¤ folder to an other folder with Windows Explorer the system "hangs up" for a
¤ couple of minutes. It seems like the databasefile is not closed. But after
¤ 2 - 3 minutes the system recover, and I can copy the file without any system
¤ "hangups".
¤
¤ This is a problem because when I try to write to or delete from the database
¤ with my program, it seems like the program also "hangs up" and I must wait
¤ 2 - 3 minutes till it recover again. Then the changes is stored.
¤
¤ This is the code I use when I try to write to the database:
¤
¤ Dim sSQL As String
¤
¤ Dim connection As String
¤
¤ connection = "provider=Micro soft.JET.OLEDB. 4.0;Data
¤ Source=J:\Besti lling.mdb"
¤
¤ sSQL = "INSERT INTO Bestillinger (StudentNummer, DatamaskinType, LeieTid)
¤ VALUES ('" & studentNr & "', '" & typeMaskin & "', '" & leiePeriode & "')"
¤
¤ Dim testConn As New System.Data.Ole Db.OleDbConnect ion(connection)
¤
¤ Dim testCmd As New System.Data.Ole Db.OleDbCommand (sSQL, testConn)
¤
¤ Try
¤
¤ testConn.Open()
¤
¤ Catch myExceptions As System.Exceptio n
¤
¤ Console.WriteLi ne(myExceptions .Message)
¤
¤ End Try
¤
¤ Console.Write(" Test", sSQL)
¤
¤ Console.ReadLin e()
¤
¤ If testConn.State = ConnectionState .Open Then
¤
¤ Try
¤
¤ testCmd.Execute NonQuery()
¤
¤ Catch myExceptions As System.Exceptio n
¤
¤ Console.WriteLi ne(myExceptions .Message)
¤
¤ Console.ReadLin e()
¤
¤ End Try
¤
¤ testConn.Close( )
¤
¤ End If
¤

Is the corresponding .LDB file deleted immediately after closing the Access database?

Not sure if this database is on a network share but this could cause some delay in closing the
database.
Paul ~~~ pc******@amerit ech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #2

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

Similar topics

4
2588
by: dustin lee | last post by:
Over the years I've gotten out of the habit of explicitly closing file objects (whether for reading or writing) since the right thing always seems to happen auto-magically (e.g. files get written to disk with no missing data). I've recently started do the same thing with database connections. I'm wondering if anyone has had trouble with this sort of "lazy" programming style. My assumption is the the database connection will get closed...
5
3045
by: nick_faye | last post by:
Hi, I am still a newbie to VB and using MS Access 2000. I am currently trying to provide a preview of reports before printing them. My program is simple: AC.DoCmd.OpenReport "MyReport", acViewPreview AC.Visible = True AC.DoCmd.ShowToolbar "Print Preview", acToolbarNo AC.DoCmd.ShowToolbar "Menu Bar", acToolbarNo
22
7569
by: alecjames1 | last post by:
I have a form which the user must complete before closing. I have disabled the window x button and use my own exit button. When selected it checks to see if the user has completed the entries otherwise it cancels the close. However, the user can still right click on the task bar and close my application. Is there any way of preventing this. Thanks Alex
0
1132
by: Brent | last post by:
I wrote a simple class to supply a datareader object (code at bottom of post) back to a page. I access it on the APSX page like this: Dim myDR as New getDataReader(strSQL) If myDR.ResultFailed = True Then MessageText.InnerHTML = "Internal error." Else
7
1404
by: darrel | last post by:
We're running into a problem on our new site. Once a week or so, our site goes down with an 'out of memory error'. Rebooting the web server fixes things. Googling the error doesn't return many results (one, actually) and the suggested fix is to make sure you are manually closing all DB connections. I'm doing that now, but I had thought that asp.net had fairly robust automated cleanup, and that having to explicitely close every connection...
7
4124
by: Arsalan | last post by:
I have a function which return datareader Public Shared Function ReturnDReader(ByVal query As String) As OleDbDataReader Dim Connection_String As String = System.Configuration.ConfigurationSettings.AppSettings("strConn") Dim conn As OleDbConnection Dim cm As OleDbCommand Dim dr As OleDbDataReader Try
11
2238
by: Nick 'The Database Guy' | last post by:
How do I acheive this, any one know. Thanks in advance. Nick
7
3250
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I am trying to develop a photoalbum (also posted a topic called "array / mysql question"). Of course I can use some wonderful open source albums but at the same time I want to get more familiar with all the ins and outs so my idea is a list of...
11
2952
by: Simon van Beek | last post by:
Dear reader, By opening an application I get always the main Access window with the closing cross in the above right corner. Is there a possibility to make this closing cross invisible? All the settings in the Start-up form under Tools are disabled but the closing cross in the above right corner is still visible.
0
8535
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
8952
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...
1
8793
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8796
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
7626
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
6457
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...
1
2968
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
2
2234
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1954
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.