|
-
Sep 21st, 2003, 09:45 PM
#1
Thread Starter
Hyperactive Member
Update Time in MSAccess / VB
Hi,
what is the best way to know when Access has finally executed a command sent to it by VB.Net ?
For instance, please review the following example:
Code:
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
Dim strNewName As String = InputBox("Please Enter The New Packages's Name:", "New Package", , Me.Left, Me.Top)
If Trim(strNewName) <> "" Then
PackageMasterInsert(strNewName)
grdPackageItems.DataSource = Nothing
LoadPackageMaster(lstPackages)
End If
End Sub
Public Function PackageMasterInsert(ByVal NewName As String)
Dim conDB As New OleDb.OleDbConnection()
conDB = ConnectToDatabase()
Dim strSQLStm As String
Dim intRowsAffected As Integer
strSQLStm = "INSERT INTO tbl_PackageMaster (pkg_Name, pkg_Description) " & _
"VALUES ('" & NewName & "', '" & " " & "')"
Debug.WriteLine(strSQLStm)
Dim cmdInsert As New OleDb.OleDbCommand(strSQLStm, conDB)
intRowsAffected = cmdInsert.ExecuteNonQuery()
End Function
Public Function LoadPackageMaster(ByVal objPackages As Object)
Dim conDB As New OleDb.OleDbConnection()
conDB = ConnectToDatabase()
Dim strSQLStm As String = "SELECT * " & _
"FROM tbl_PackageMaster " & _
"ORDER BY pkg_Name"
Dim cmdPkg As New OleDb.OleDbCommand(strSQLStm, conDB)
Dim datPkg As OleDb.OleDbDataReader
objPackages.Items.Clear()
datPkg = cmdPkg.ExecuteReader
Do Until datPkg.Read = False
objPackages.Items.Add(New ListItem(datPkg("pkg_Name"), datPkg("pkg_ID")))
Loop
datPkg.Close()
End Function
What happens in 99% of the times i run this, is that the Loading of the Packages takes place before the insert of the new package has finished. Hence, when the list box is reloaded, the new package is not there.
If put in a timer and say wait for 3-5 seconds, then the next package is there.
This is happening on a PC with Ado.Net to Access 2K and all files are on my local drive.
Any suggestions?
cheers.
Last edited by stingrae; Sep 21st, 2003 at 11:47 PM.
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
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
|