最好不要通过Execute来检验,速度要快.

解决方案 »

  1.   

    Quick SQL Pass-Through Queries
    The fastest way to work with ODBC data sources is via attached tables. See the article DAO External: Working with External Data Sources. For doing bulk operations, the best, and often fastest, approach is to use an SQL pass-through query. It’s possible to do a quick pass-through query using a recordset and without having to create a querydef, even a temporary one. This is also helpful if you’re converting existing code that uses the DB_SQLPASSTHROUGH option in many places.DAO’s Connect property for databases normally doesn’t have a value for Microsoft Jet (.MDB) databases. But you can assign an ODBC connect string to the property and use the dbSQLPassthrough option in a recordset. This means you don’t have to open the ODBC data source directly to use SQL pass-through.For example:// pdb is a pointer to a CDaoDatabase object 
    // (an .MDB database)
    // Set up the connect string
    CString strConnect = "ODBC;DSN=ntstuff;UID=sa;PWD=Fred;APP=App Name;WSID=MyComputer;DATABASE=pubs;TABLE=dbo.authors;";
    pdb->SetConnect( strConnect );
    // Use SQL pass-through in a recordset
    // Set up the SQL and open the recordset
    CString strSQL = "whatever";
    CDaoRecordset rs( pdb );
    try
    {
        rs.Open( dbOpenSnapshot, strSQL, dbSQLPassThrough );
        // ...
    }
    // ...
      

  2.   

    不同的数据库SQL有区别,怎么检验??
      

  3.   

    好象只能通过执行SQL的方法,EXECUTE没有返回的;建议使用OPEN,如上。