472,127 Members | 1,499 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 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 1448
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by dustin lee | last post: by
22 posts views Thread by alecjames1 | last post: by
reply views Thread by Brent | last post: by
7 posts views Thread by darrel | last post: by
7 posts views Thread by Arsalan | last post: by
11 posts views Thread by Nick 'The Database Guy' | last post: by
7 posts views Thread by Martien van Wanrooij | last post: by
reply views Thread by leo001 | last post: by

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.