PC Review


Reply
Thread Tools Rate Thread

Closing database in VB .Net

 
 
Vegar Hansen
Guest
Posts: n/a
 
      31st Oct 2003
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


 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      31st Oct 2003
On Fri, 31 Oct 2003 18:43:47 +0100, "Vegar Hansen" <(E-Mail Removed)> 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 ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing another database with VBA Gaetan Microsoft Access 1 5th Feb 2008 09:20 AM
closing database =?Utf-8?B?bWhtYWlk?= Microsoft Access Form Coding 2 26th Jan 2007 03:51 AM
closing another database =?Utf-8?B?THVpcw==?= Microsoft Access VBA Modules 1 30th Mar 2006 10:29 PM
RE: VBA for Closing Database =?Utf-8?B?RnJhbmsgV2FnbmVy?= Microsoft Access Form Coding 0 22nd Sep 2005 05:23 PM
Multiple OutputTo (Called on Closing Form) Fails on Closing Database John Andrews Microsoft Access Macros 3 21st May 2004 08:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:41 PM.