HELP ADO and ADOX timing problems :-( 
Author Message
 HELP ADO and ADOX timing problems :-(

Hi
I'm having some trouble with ADO and ADOX and timing. I'm trying to
create fields runtime and then to write to the
table with the new fields. I'm using the BeginTrans and CommitTrans of
my ADODB.Connection object.
When I make a new column in my table everything seems to go ok. if I
then wait for about 6 seconds I can also Write
and read to and from the new field in my table, but if I don't wait for
6 seconds after i recieve the
db_CommitTransComplete event i get an error saying that the Table
doesn't exist !!? ##"#""#!! grr.

I'm Running VB 6.0 SP3 with an Access97 Database.

My code looks something like this:  (I have only copy/pasted some of it)

Dim WithEvents db As ADODB.Connection
Public cat As adox.Catalog
Public tbl As adox.Table
Public bolTransComitted As Boolean
 .
 .
 .
 .
Public Sub auxCreateAColumn(TableName As String, ColumnName As String,
AsDataType As String, allowNull As Boolean)

    Dim myCol As New adox.Column

    db.BeginTrans

        myCol.Name = ColumnName
        If allowNull Then myCol.Attributes = adColNullable
        myCol.Type = AsDataType

        cat.Tables(TableName).Columns.Append myCol
        DoEvents
        cat.Tables.Refresh

        DoEvents
        Set myCol = Nothing
    db.CommitTrans

    While bolTransComitted = False 'In the event hadler for
db_CommitTransComplete
     'I set the Boolean to true. Now i Wait for it to be True.
        Sleep (100)
    Wend

End Sub

'The above works just fine

'After this I Try to open a recordset with the table

Dim tblAuxCondition As ADODB.Recordset
Set tblAuxCondition = New ADODB.Recordset

tblAuxCondition.Open "SELECT * FROM AuxCondition", db, adOpenDynamic,
adLockOptimistic

Here I sometimes get an Error saying that the table does not exist, or
later on when I try to write to the newly added field I get an error
saying that the field does not exist. If I wait for about 6 seconds or
more from I have created the field and until i Write to it everytihing
works just fine. If I'm just waiting for 100 msec I always get an error.

Now...Am I using the ADOX in a wrong way ? Is there any other way to
know when a field has been added to the database instead of using the
db_CommitTransComplete event ??

I hope someone can help me.

Best Regards Lars Iversen



Fri, 25 Oct 2002 03:00:00 GMT
 
 [ 1 post ] 

 Relevant Pages 

1. HELP ADO and ADOX timing problems :-(

2. ADO and ADOX header file macro clashes problem

3. Delete-problem in ADO (Table created in ADOX)

4. ADO and ADOX problem...

5. ADO and ADOX header file macro clashes problem

6. ADO/ADOX problem!

7. ADOX and ADO problem?

8. ADO / ADOX problem

9. ADO / ADOX problem

10. Using ADO 2.1 / ADOX / ADO 2.0 with C++

11. Using ADO 2.1 / ADOX / ADO 2.0 with C++

12. Creating Table in ADOX has a timing issue


 
Powered by phpBB® Forum Software