|
-
Sep 30th, 2008, 06:15 PM
#1
Thread Starter
Hyperactive Member
[2008] .MDB File in use Already?
Alright, Here's what is happening:
I have a .MDB File that gets created and inserted with DATA. I then have the CONNECTION.CLOSE, but then say I go to Delete It, it says that it is being used already, I check my Process and doesn't show anything. This only happens in the first 5 Seconds after creating and trying to delete, after the 5 seconds, it will work normal. I know this sounds weird, but how can I make it to not be used in the process right after Connection.Close is Called?
Here's my Code:
vb Code:
Public Function CreateCourse(ByVal DBDirectory As String) As Boolean
Dim DB As New ADOX.Catalog()
Try
Application.DoEvents()
With frmNewEditCourse
DB.Create(Connection.ConnectionString)
SQL = "CREATE TABLE [Information] ([CIndex] AutoIncrement, [CourseCode] TEXT, [RoomNumber] TEXT, [CourseYear] TEXT, [Teacher] Text)"
Command = New OleDbCommand(SQL, Connection)
Command.Connection.Open()
Command.ExecuteNonQuery()
SQL = "CREATE TABLE [Students] ([CIndex] AutoIncrement, [LastName] TEXT, [FirstName] TEXT)"
Command = New OleDbCommand(SQL, Connection)
Command.ExecuteNonQuery()
SQL = "CREATE TABLE [Events] ([CIndex] AutoIncrement, [Date (D/M/Y)] TEXT, [EventTitle] TEXT, [EventDesc] TEXT)"
Command = New OleDbCommand(SQL, Connection)
Command.ExecuteNonQuery()
Command.Connection.Close()
If bImportCourse = False Then
SQL = "INSERT INTO [Information] (CourseCode, RoomNumber, CourseYear, Teacher) VALUES (?, ?, ?, ?); "
Command = New OleDbCommand(SQL, Connection)
Command.Connection.Open()
Command.Parameters.AddWithValue("CourseCode", .txtCourseCode.Text)
Command.Parameters.AddWithValue("RoomNumber", .txtRoomNumber.Text)
Command.Parameters.AddWithValue("CourseYear", .txtCourseYear.Text)
Command.Parameters.AddWithValue("Teacher", .txtTeacher.Text)
Command.ExecuteNonQuery()
Command.Connection.Close()
frmStartup.lstCourses.Items.Add(.txtCourseCode.Text)
End If
End With
Catch Excep As System.Runtime.InteropServices.COMException
Finally
DB = Nothing
End Try
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|