473,404 Members | 2,137 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,404 software developers and data experts.

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=Microsoft.JET.OLEDB.4.0;Data
Source=J:\Bestilling.mdb"

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

Dim testConn As New System.Data.OleDb.OleDbConnection(connection)

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

Try

testConn.Open()

Catch myExceptions As System.Exception

Console.WriteLine(myExceptions.Message)

End Try

Console.Write("Test", sSQL)

Console.ReadLine()

If testConn.State = ConnectionState.Open Then

Try

testCmd.ExecuteNonQuery()

Catch myExceptions As System.Exception

Console.WriteLine(myExceptions.Message)

Console.ReadLine()

End Try

testConn.Close()

End If
Nov 20 '05 #1
1 1499
On Fri, 31 Oct 2003 18:43:47 +0100, "Vegar Hansen" <ve**********@broadpark.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=Microsoft.JET.OLEDB.4.0;Data
¤ Source=J:\Bestilling.mdb"
¤
¤ sSQL = "INSERT INTO Bestillinger (StudentNummer, DatamaskinType, LeieTid)
¤ VALUES ('" & studentNr & "', '" & typeMaskin & "', '" & leiePeriode & "')"
¤
¤ Dim testConn As New System.Data.OleDb.OleDbConnection(connection)
¤
¤ Dim testCmd As New System.Data.OleDb.OleDbCommand(sSQL, testConn)
¤
¤ Try
¤
¤ testConn.Open()
¤
¤ Catch myExceptions As System.Exception
¤
¤ Console.WriteLine(myExceptions.Message)
¤
¤ End Try
¤
¤ Console.Write("Test", sSQL)
¤
¤ Console.ReadLine()
¤
¤ If testConn.State = ConnectionState.Open Then
¤
¤ Try
¤
¤ testCmd.ExecuteNonQuery()
¤
¤ Catch myExceptions As System.Exception
¤
¤ Console.WriteLine(myExceptions.Message)
¤
¤ Console.ReadLine()
¤
¤ 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******@ameritech.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
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...
5
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",...
22
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...
0
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...
7
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...
7
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 =...
11
by: Nick 'The Database Guy' | last post by:
How do I acheive this, any one know. Thanks in advance. Nick
7
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...
11
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? ...
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: 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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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
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.