📄 vcg13.htm
字号:
<TD COLSPAN=2 ALIGN=center VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Data Members</I>
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
m_pDatabase
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Contains a pointer to the CDaoDatabase object to which the Querydef is associated, whether the Querydef is saved or not.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
m_pDAOQueryDef
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Contains a pointer to the OLE interface for the underlying DAO Querydef object.
</FONT>
<TR>
<TD COLSPAN=2 ALIGN=center VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Construction</I>
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
CDaoQueryDef()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Constructs the CDaoQueryDef object. After the CDaoQueryDef object is created, you must call either Open() or Create().
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Create()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Creates the underlying DAO Querydef object. The query can be either temporary or saved using a call to the Append() member function.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Append()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Appends the Querydef to the database's QueryDefs collection. This will make the Querydef a saved (not temporary) object.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Open()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Opens an existing Querydef stored in the database's QueryDefs collection.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Close()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Closes the Querydef object.
</FONT>
<TR>
<TD COLSPAN=2 VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Attributes
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
CanUpdate()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Returns a zero result if the database can't be updated.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetConnect()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Obtains the connect string associated with the Querydef.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetDateCreated()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Obtains the query's creation date.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetDateLastUpdated()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Obtains the query's last update date.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetName()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Returns the name of the Querydef.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetODBCTimeout()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Obtains the ODBC timeout value.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetRecordsAffected()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines the count of how many records have been affected by an action query.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetReturnsRecords()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Returns zero if the query doesn't return any records.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetSQL()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Returns the SQL string that specifies the query defined by the Querydef.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetType()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines what the query type is. The query type could be delete, update, append, make-table, and so on.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
IsOpen()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Returns zero if the Querydef isn't open or can't be executed.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
SetConnect()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Sets the connect string for an SQL pass-through query on an ODBC data source.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
SetName()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Sets the name of the saved query. This new name replaces the name that was in use when the Querydef was created.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
SetODBCTimeout()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Sets the timeout period to be used by ODBC.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
SetReturnsRecords()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Specifies that the Querydef will return records.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
SetSQL()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Sets the SQL string that specifies the query defined by the Querydef.
</FONT>
<TR>
<TD COLSPAN=2 ALIGN=center VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Operations</I>
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Execute()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Executes the query defined by the Querydef object.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetFieldCount()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines the number of fields that this Querydef has defined.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetFieldInfo()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines information about a field that is specified in the query.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetParameterCount()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Determines the number of parameters defined for the query.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetParameterInfo()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Obtains information about the specified parameter in the query.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
GetParamValue()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Gets the value of a specified parameter to the query.
</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
SetParamValue()
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Sets the value of a specified parameter to the query.</FONT>
</TABLE></CENTER><BR>
<A NAME="E69E199"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B><I>CDaoRecordset</I></B></FONT></CENTER></H4>
<BR>
<P>The DAO class CDaoRecordset is used to represent a set of records that have been selected from a datasource. CDaoRecordset corresponds directly to the CRecordset object that is used with ODBC.
<BR>
<P>The main difference between the DAO recordset and the ODBC recordset is that CDaoRecordset class objects access data through DAO, which is based on OLE, while the CRecordset classes access the database using ODBC.
<BR>
<P>A CDaoRecordset object is known as a recordset. A CDaoRecordset object can take one of three forms: a table-type recordset, a dynaset-type recordset, or a snapshot-type recordset:
<BR>
<UL>
<LI>The table-type recordset represents a base table that you can use to examine records, change records, add records to, or delete records from a single database table.
<BR>
<BR>
<LI>The dynaset-type recordset is the result of a query that can have records that are updatable. The dynaset-type recordset comprises a set of records that may be examined, added to, changed, or deleted from an underlying database table or tables. The dynaset-type recordset may contain fields from more than one table in a database if necessary.
<BR>
<BR>
<LI>The snapshot-type recordset contains a static copy of a set of records returned from a query. This static set of records can be used to display information or create graphs or reports. Like a dynaset, a snapshot-type recordset may contain fields from one or more tables in a database.
<BR>
<BR>
</UL>
<P>The records contained in the recordset are fixed at the time the recordset is opened. Both the table-type recordset and dynaset-type recordset will reflect any changes made to data after the recordset was opened (by either the current process or perhaps by other users). In contrast, the snapshot recordset is static and isn't updated. Many applications use CDaoRecordset directly (usually using classes created using AppWizard). However, you can derive a class from CDaoRecordset if you wish. When you have a recordset object, you can do the following:
<BR>
<UL>
<LI>Use a filter to limit the records selected from the recordset.
<BR>
<BR>
<LI>Scroll through the records either forwards or backwards.
<BR>
<BR>
<LI>With dynaset-type and snapshot-type recordsets, you can use comparison operations to find records. Typical operations include <, <=, =, >=, and >.
<BR>
<BR>
<LI>With table-type recordsets, you can create an index and use the Seek() member function.
<BR>
<BR>
<LI>With dynaset-type and table-type recordsets, you can update the records and specify a locking mode.
<BR>
<BR>
<LI>Sort the recordset.
<BR>
<BR>
<LI>At runtime, you can parameterize the recordset. This will serve to limit the records selected into the recordset.
<BR>
<BR>
</UL>
<P>To use the CDaoRecordset object, first you must open a database and construct your CDaoRecordset object. A pointer to your CDaoDatabase object must be passed to the constructor. Alternatively, it's possible to create a CDaoRecordset object and have MFC create a temporary CDaoDatabase object.
<BR>
<P>After you've created the CDaoRecordset, you must call the Open() member function. It takes a parameter that specifies whether the object is to be a table-type recordset, a dynaset-type recordset, or a snapshot-type recordset. Calling Open() selects data from the database and retrieves the first record.
<BR>
<P>After you've created your recordset object, you then can use the object's member functions and data members to scroll through the records and perform operations on them.
<BR>
<P>The CDaoRecordset class uses DAO record field exchange (DFX) to support the reading and updating of record fields through type-safe C++ members of your CDaoRecordset or CDaoRecordset-derived class. See the CDaoFieldExchange object in the Visual C++ Books Online for more information.
<BR>
<P>Table 13.6 lists the members of the CDaoRecordset class.
<BR>
<BR>
<P ALIGN=CENTER>
<CENTER>
<FONT COLOR="#000080"><B>Table 13.6. The CDaoRecordset class members.</B></FONT></CENTER>
<BR>
<CENTER><TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Member</I>
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
<I>Descrip
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -