使用Command对象的Execute方法,如MyCommand->Execute("INSERT INTO .....",....);
Connection也有执行SQL语句的方法。
以CDaoDatabase::Execute()为例:void Execute( LPCTSTR lpszSQL, int nOptions = 0 ); throw( CDaoException, CMemoryException );ParameterslpszSQLPointer to a null-terminated string containing a valid SQL command to execute.nOptionsAn integer that specifies options relating to the integrity of the query. You can use the bitwise-OR operator (|) to combine any of the following constants (provided the combination makes sense — for example, you would not combine dbInconsistent with dbConsistent): dbDenyWrite Deny write permission to other users. dbInconsistent (Default) Inconsistent updates. dbConsistent Consistent updates. dbSQLPassThrough SQL pass-through. Causes the SQL statement to be passed to an ODBC data source for processing. dbFailOnError Roll back updates if an error occurs. dbSeeChanges Generate a run-time error if another user is changing data you are editing. Note If both dbInconsistent and dbConsistent are included or if neither is included, the result is the default. For an explanation of these constants, see the topic "Execute Method" in DAO Help.其他Execute你在MSDN里面一查就知道了。
throw( CDaoException, CMemoryException );ParameterslpszSQLPointer to a null-terminated string containing a valid SQL command to execute.nOptionsAn integer that specifies options relating to the integrity of the query. You can use the bitwise-OR operator (|) to combine any of the following constants (provided the combination makes sense — for example, you would not combine dbInconsistent with dbConsistent): dbDenyWrite Deny write permission to other users.
dbInconsistent (Default) Inconsistent updates.
dbConsistent Consistent updates.
dbSQLPassThrough SQL pass-through. Causes the SQL statement to be passed to an ODBC data source for processing.
dbFailOnError Roll back updates if an error occurs.
dbSeeChanges Generate a run-time error if another user is changing data you are editing.
Note If both dbInconsistent and dbConsistent are included or if neither is included, the result is the default. For an explanation of these constants, see the topic "Execute Method" in DAO Help.其他Execute你在MSDN里面一查就知道了。