Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Help with Error


Message #1 by JMATTHIS@c... on Mon, 8 Jan 2001 15:35:34 -0500
When I run this code:
    ' Create ODBC Workspace object.
    Set WS = DBEngine.CreateWorkspace("ODBCDirect", "admin", "", dbUseODBC)

    'Open ODBC Connection as CN
    Set CN = WS.OpenConnection("ODBCConnect", dbDriverNoPrompt, False,
ConnectString)
    
    'Create Indistinct table
    SQL = "IF EXISTS(SELECT * FROM sysobjects WHERE id = " & _
          "object_id('Indistinct')) DROP TABLE Indistinct"
    CN.Execute (SQL)
    SQL = "SELECT .....STUFF ... INTO Indistinct " ' I'm omitting the gory
details because this query works
    CN.Execute (SQL)
    'Clear DistinctRecords table
    SQL = "Delete From DistinctRecords"
    CN.Execute (SQL)
    'Fill RST with distinct Contact_IDs
    SQL = "Select distinct Contact_ID from Indistinct"
    Set rst = CN.OpenRecordset(SQL)
    With rst
        SixPercent = CN.RecordsAffected
        SixPercent = (0.06 * SixPercent)
        While Not .EOF And SixPercent > 0
            Set QDF = CN.CreateQueryDef("")
            'Insert one row for each Contact_ID
            SQL = "INSERT INTO DistinctRecords Select * From Indistinct
Where Contact_ID = '" & Trim(rst.Fields(0)) & "'"
            QDF.MaxRecords = 1
            QDF.Execute (SQL)
            SixPercent = SixPercent - 1
            'RST2.Close
            .MoveNext
        Wend
        .Close
    End With
'END CODE
When the QDF.execute runs I get an ERROR: "Invalid SQL statement: expected
"DELETE", "INSERT", "PROCEDURE", "SELECT" or "UPDATE' 
Error Number 3129.
WHY am I getting this error? The same query runs when I use a pass through
query.


Judy Matthis
Delivery Systems
(xxx) xxx-xxxx
jmatthis@c...


---
You are currently subscribed to sql_language as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-sql_language-$subst('Recip.MemberIDChar')@p2p.wrox.com

  Return to Index