recrdset.tex

来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 607 行 · 第 1/2 页

TEX
607
字号
\section{\class{wxRecordSet}}\label{wxrecordset}

Each wxRecordSet represents an ODBC database query. You can make multiple queries
at a time by using multiple wxRecordSets with a wxDatabase or you can make
your queries in sequential order using the same wxRecordSet.

Note: this class is considered obsolete, replaced by the Remstar 
wxDB/wxDbTable classes

\wxheading{Derived from}

\helpref{wxObject}{wxobject}

\wxheading{Include files}

<wx/odbc.h>

\wxheading{See also}

\helpref{wxRecordSet overview}{wxrecordsetoverview}, \helpref{wxDatabase overview}{wxdatabaseoverview}

\latexignore{\rtfignore{\wxheading{Members}}}

\membersection{wxRecordSet::wxRecordSet}

\func{}{wxRecordSet}{\param{wxDatabase *}{db}, \param{int}{ type = wxOPEN\_TYPE\_DYNASET},
 \param{int}{ opt = wxOPTION\_DEFAULT}}

Constructor. {\it db} is a pointer to the wxDatabase instance you wish to use the
wxRecordSet with. Currently there are two possible values of {\it type}:

\begin{itemize}\itemsep=0pt
\item wxOPEN\_TYPE\_DYNASET: Loads only one record at a time into memory. The other
data of the result set will be loaded dynamically when
moving the cursor. This is the default type.
\item wxOPEN\_TYPE\_SNAPSHOT: Loads all records of a result set at once. This will
need much more memory, but will result in
faster access to the ODBC data.
\end{itemize}

The {\it option} parameter is not used yet.

The constructor appends the wxRecordSet object to the parent database's list of
wxRecordSet objects, for later destruction when the wxDatabase is destroyed.

\membersection{wxRecordSet::\destruct{wxRecordSet}}

\func{}{\destruct{wxRecordSet}}{\void}

Destructor. All data except that stored in user-defined variables will be lost.
It also unlinks the wxRecordSet object from the parent database's list of
wxRecordSet objects.
 
\membersection{wxRecordSet::AddNew}

\func{void}{AddNew}{\void}

Not implemented.

\membersection{wxRecordSet::BeginQuery}

\func{bool}{BeginQuery}{\param{int}{ openType}, \param{const wxString\& }{sql = NULL}, \param{int}{ options = wxOPTION\_DEFAULT}}

Not implemented.

\membersection{wxRecordSet::BindVar}

\func{void *}{BindVar}{\param{int}{ col}, \param{void *}{buf}, \param{long}{ size}}

Binds a user-defined variable to the column col. Whenever the current field's
data changes, it will be copied into buf (maximum {\it size} bytes).

\func{void *}{BindVar}{\param{const wxString\& }{col}, \param{void *}{buf}, \param{long}{ size}}

The same as above, but uses the column name as the identifier.

\membersection{wxRecordSet::CanAppend}

\func{bool}{CanAppend}{\void}

Not implemented.

\membersection{wxRecordSet::Cancel}

\func{void}{Cancel}{\void}

Not implemented.

\membersection{wxRecordSet::CanRestart}

\func{bool}{CanRestart}{\void}

Not implemented.

\membersection{wxRecordSet::CanScroll}

\func{bool}{CanScroll}{\void}

Not implemented.

\membersection{wxRecordSet::CanTransact}

\func{bool}{CanTransact}{\void}

Not implemented.

\membersection{wxRecordSet::CanUpdate}

\func{bool}{CanUpdate}{\void}

Not implemented.

\membersection{wxRecordSet::ConstructDefaultSQL}

\func{bool}{ConstructDefaultSQL}{\void}

Not implemented.

\membersection{wxRecordSet::Delete}

\func{bool}{Delete}{\void}

Deletes the current record. Not implemented.

\membersection{wxRecordSet::Edit}

\func{void}{Edit}{\void}

Not implemented.

\membersection{wxRecordSet::EndQuery}

\func{bool}{EndQuery}{\void}

Not implemented.

\membersection{wxRecordSet::ExecuteSQL}\label{wxrecordsetexecutesql}

\func{bool}{ExecuteSQL}{\param{const wxString\& }{sql}}

Directly executes a SQL statement. The data will be presented as a normal
result set. Note that the recordset must have been created as a snapshot, not
dynaset. Dynasets will be implemented in the near future.

Examples of common SQL statements are given in \helpref{A selection of SQL commands}{sqlcommands}.

\membersection{wxRecordSet::FillVars}

\func{void}{FillVars}{\param{int}{ recnum}}

Fills in the user-defined variables of the columns. You can set these
variables with wxQueryCol::BindVar. This function will be automatically
called after every successful database operation.

\membersection{wxRecordSet::GetColName}

\func{wxString}{GetColName}{\param{int}{ col}}

Returns the name of the column at position {\it col}. Returns NULL if {\it col} does not
exist.

\membersection{wxRecordSet::GetColType}

\func{short}{GetColType}{\param{int}{ col}}

Returns the data type of the column at position {\it col}. Returns SQL\_TYPE\_NULL
if {\it col} does not exist.

\func{short}{GetColType}{\param{const wxString\& }{ name}}

The same as above, but uses the column name as the identifier.

See \helpref{ODBC SQL data types}{sqltypes} for a list
of possible data types.

\membersection{wxRecordSet::GetColumns}

\func{bool}{GetColumns}{\param{const wxString\& }{table = NULL}}

Returns the columns of the table with the specified name. If no name is
given the class member {\it tablename} will be used. If both names are NULL
nothing will happen. The data will be presented as a normal result set, organized
as follows:

\begin{twocollist}\itemsep=0pt
\twocolitem{0 (VARCHAR)}{TABLE\_QUALIFIER}
\twocolitem{1 (VARCHAR)}{TABLE\_OWNER}
\twocolitem{2 (VARCHAR)}{TABLE\_NAME}
\twocolitem{3 (VARCHAR)}{COLUMN\_NAME}
\twocolitem{4 (SMALLINT)}{DATA\_TYPE}
\twocolitem{5 (VARCHAR)}{TYPE\_NAME}
\twocolitem{6 (INTEGER)}{PRECISION}
\twocolitem{7 (INTEGER)}{LENGTH}
\twocolitem{8 (SMALLINT)}{SCALE}
\twocolitem{9 (SMALLINT)}{RADIX}
\twocolitem{10 (SMALLINT)}{NULLABLE}
\twocolitem{11 (VARCHAR)}{REMARKS}
\end{twocollist}

\membersection{wxRecordSet::GetCurrentRecord}

\func{long}{GetCurrentRecord}{\void}

Not implemented.

\membersection{wxRecordSet::GetDatabase}

\func{wxDatabase *}{GetDatabase}{\void}

Returns the wxDatabase object bound to a wxRecordSet.

\membersection{wxRecordSet::GetDataSources}\label{wxrecordsetgetdatasources}

\func{bool}{GetDataSources}{\void}

Gets the currently-defined data sources via the ODBC manager. The data will be presented
as a normal result set. See the documentation for the ODBC function SQLDataSources for how the data
is organized.

Example:
  
\begin{verbatim}
  wxDatabase Database;

  wxRecordSet *Record = new wxRecordSet(&Database);

  if (!Record->GetDataSources()) {
    char buf[300];
    sprintf(buf, "%s %s\n", Database.GetErrorClass(), Database.GetErrorMessage());
    frame->output->SetValue(buf);
  }
  else {
    do {
      frame->DataSource->Append((char*)Record->GetFieldDataPtr(0, SQL_CHAR));
    } while (Record->MoveNext());
  }
\end{verbatim}

\membersection{wxRecordSet::GetDefaultConnect}

\func{wxString}{GetDefaultConnect}{\void}

Not implemented.

\membersection{wxRecordSet::GetDefaultSQL}

\func{wxString}{GetDefaultSQL}{\void}

Not implemented.

\membersection{wxRecordSet::GetErrorCode}

\func{wxRETCODE}{GetErrorCode}{\void}

Returns the error code of the last ODBC action. This will be one of:

\begin{twocollist}\itemsep=0pt
\twocolitem{SQL\_ERROR}{General error.}
\twocolitem{SQL\_INVALID\_HANDLE}{An invalid handle was passed to an ODBC function.}
\twocolitem{SQL\_NEED\_DATA}{ODBC expected some data.}
\twocolitem{SQL\_NO\_DATA\_FOUND}{No data was found by this ODBC call.}
\twocolitem{SQL\_SUCCESS}{The call was successful.}
\twocolitem{SQL\_SUCCESS\_WITH\_INFO}{The call was successful, but further information can be
obtained from the ODBC manager.}
\end{twocollist}

\membersection{wxRecordSet::GetFieldData}\label{wxrecordsetgetfielddata}

\func{bool}{GetFieldData}{\param{int}{ col}, \param{int}{ dataType}, \param{void *}{dataPtr}}

Copies the current data of the column at position {\it col} into the buffer
\rtfsp{\it dataPtr}. To be sure to get the right type of data, the user has to pass the
correct data type. The function returns false if {\it col} does not
exist or the wrong data type was given.

\func{bool}{GetFieldData}{\param{const wxString\& }{name}, \param{int}{ dataType}, \param{void *}{dataPtr}}

The same as above, but uses the column name as the identifier.

See \helpref{ODBC SQL data types}{sqltypes} for a list
of possible data types.

\membersection{wxRecordSet::GetFieldDataPtr}\label{wxrecordsetgetfielddataptr}

\func{void *}{GetFieldDataPtr}{\param{int}{ col}, \param{int}{ dataType}}

Returns the current data pointer of the column at position {\it col}.
To be sure to get the right type of data, the user has to pass the
data type. Returns NULL if {\it col} does not exist or if {\it dataType} is
incorrect.

\func{void *}{GetFieldDataPtr}{\param{const wxString\& }{name}, \param{int}{ dataType}}

The same as above, but uses the column name as the identifier.

See \helpref{ODBC SQL data types}{sqltypes} for a list
of possible data types.

\membersection{wxRecordSet::GetFilter}

\func{wxString}{GetFilter}{\void}

Returns the current filter.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?