ADODC Refresh after command execution problem

ADODC Refresh after command execution problem

Post by wjcot » Mon, 12 Nov 2001 08:28:57



I am having problems with the refresh of my ADO Data Control after I have
executed  a SQL statement by the command object. It seems that my code
progresses before the command has been completely finished. I have in my
code a ADODC object refresh after the execution that does not have the new
values.

I am using VB 6.0 SP 5 and my code is as follows:

Option Explicit

Dim selectedOption As Integer
Dim myCommand As ADODB.Command
Dim WithEvents myConnection As ADODB.Connection

Private Sub myConnection_ExecuteComplete(ByVal RecordsAffected As Long,
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal
pCommand As ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal
pConnection As ADODB.Connection)
    Dim startTime As Date
    startTime = Now + TimeValue("00:00:03")
    Do While Now < startTime
        DoEvents
    Loop
    ADODC1.Refresh
End Sub

Private Sub cmdDelete_Click()
    Dim enteredNumber As Variant
    Dim startTime As Date
    enteredNumber = InputBox("Please enter the part number that is to be
deleted", "Part Deletion")
    myCommand.CommandText = "DELETE * FROM tblInventory WHERE fldPartNum = "
& enteredNumber
    myCommand.Execute
End Sub

Private Sub cmdExit_Click()
    myConnection.Close
    Set myConnection = Nothing
    End
End Sub

Private Sub cmdUpdate_Click()
    Dim T As Double
    If (IsNumeric(txtPriceIncrease.Text) = True Or txtPriceIncrease.Text =
"") And selectedOption > 0 Then
        myCommand.CommandText = "UPDATE tblInventory SET fldCost = fldCost *
" & (1 + (txtPriceIncrease.Text / 100)) & " WHERE fldCategory = " &
selectedOption + 1
        myCommand.Execute
    End If
End Sub

Private Sub Form_Load()
    Set myConnection = New ADODB.Connection
    Set myCommand = New ADODB.Command
    myConnection.Provider = "Microsoft.Jet.OLEDB.4.0"
    myConnection.Open ConnectionString:="data source=" & App.Path &
"\Inventory.mdb;" & _
        "Provider=Microsoft.Jet.OLEDB.4.0;"
    myCommand.ActiveConnection = myConnection
    myCommand.CommandType = adCmdText
End Sub

Private Sub opCategory_Click(Index As Integer)
    ADODC1.RecordSource = "SELECT * FROM tblInventory WHERE fldCategory=" &
Index + 1
    ADODC1.Refresh
    selectedOption = Index
End Sub

As you can see, I have implemented a 3 second timer to temporarily get the
desired results. Since it does work with the timer it must be a timing
problem. Any help would be greatly appreciated.

Bill

 
 
 

ADODC Refresh after command execution problem

Post by Douglas Laudenschlager [M » Fri, 16 Nov 2001 10:15:28


Bill,

Jet caches your new records on the one connection before writing them out,
so they're not available immediately on the other connection.

Please see Knowledge Base article Q200300, "HOWTO: Synchronize Writes and
Reads with the Jet OLE DB".

Using a single connection when feasible for all interaction with a single
Jet database will minimize this problem.

This posting is provided AS IS with no warranties, and confers no rights.

 
 
 

ADODC Refresh after command execution problem

Post by wjcot » Tue, 20 Nov 2001 10:43:38




Quote:

> Bill,

> Jet caches your new records on the one connection before writing them out,
> so they're not available immediately on the other connection.

> Please see Knowledge Base article Q200300, "HOWTO: Synchronize Writes and
> Reads with the Jet OLE DB".

> Using a single connection when feasible for all interaction with a single
> Jet database will minimize this problem.

> This posting is provided "AS IS" with no warranties, and confers no
rights.

A belated thank you very much. I understand now. Unfortunately, the manner
in which this was supposed to work was specified as an assignment. I will
have to inform my instructor of the flaw in this assignment.

Bill

 
 
 

1. Help needed: ADODC refresh problem

Can anybody help?
I am writing a program in VB6 with a DataCombo using ADODC connected do mdb
datasource.
I have a problem that I cannot seem to solve:
When I try to refresh the object (the ADODC) after updating the datasource -
it refreshes ONLY AFTER THE SECOND ROUND and it only refreshes the one
before last - so everytime I insert
a new record, the one previuos to it appears in the DataGrid object..
BUT - when I step into the code with F8 it works fine!
I tried almost everything and it will not work properly.
The most annoying thing is that in another form the process works just
fine...
Can anybody think of a solution for this?

Thank you anyway...
Eyal Porat

--
Eyal Porat

--
Eyal Porat

2. DBINFO options

3. Adodc.recordset.refresh problems (a bug?)

4. strange behaviour of SqlServer-Stored Procedure

5. ADODC Refresh method causing problems with VB

6. Windows 2000 - Millenium Edition

7. Batching inserts & updates

8. problem with ADODC command & MshFlexgrid

9. ADO Data Environment Child Command refreshing problem

10. refreshing an adodc data control hangs my program!!!

11. ADODC.Refresh

12. ADODC.Refresh triggers new connections