Every database object represents an ODBC connection. The connection may be closed and reopened.
Derived from
Include files
<wx/odbc.h>
See also
wxDatabase overview, wxRecordSet
A much more robust and feature-rich set of ODBC classes is now available and recommended for use in place of the wxDatabase class.
See details of these classes in: wxDb, wxDbTable
Members
wxDatabase::wxDatabase
wxDatabase::~wxDatabase
wxDatabase::BeginTrans
wxDatabase::Cancel
wxDatabase::CanTransact
wxDatabase::CanUpdate
wxDatabase::Close
wxDatabase::CommitTrans
wxDatabase::ErrorOccured
wxDatabase::ErrorSnapshot
wxDatabase::GetDatabaseName
wxDatabase::GetDataSource
wxDatabase::GetErrorClass
wxDatabase::GetErrorCode
wxDatabase::GetErrorMessage
wxDatabase::GetErrorNumber
wxDatabase::GetHDBC
wxDatabase::GetHENV
wxDatabase::GetInfo
wxDatabase::GetPassword
wxDatabase::GetUsername
wxDatabase::GetODBCVersionFloat
wxDatabase::GetODBCVersionString
wxDatabase::InWaitForDataSource
wxDatabase::IsOpen
wxDatabase::Open
wxDatabase::OnSetOptions
wxDatabase::OnWaitForDataSource
wxDatabase::RollbackTrans
wxDatabase::SetDataSource
wxDatabase::SetLoginTimeout
wxDatabase::SetPassword
wxDatabase::SetSynchronousMode
wxDatabase::SetQueryTimeout
wxDatabase::SetUsername
wxDatabase()
Constructor. The constructor of the first wxDatabase instance of an application initializes the ODBC manager.
~wxDatabase()
Destructor. Resets and destroys any associated wxRecordSet instances.
The destructor of the last wxDatabase instance will deinitialize the ODBC manager.
bool BeginTrans()
Not implemented.
void Cancel()
Not implemented.
bool CanTransact()
Not implemented.
bool CanUpdate()
Not implemented.
bool Close()
Resets the statement handles of any associated wxRecordSet objects, and disconnects from the current data source.
bool CommitTrans()
Commits previous transactions. Not implemented.
bool ErrorOccured()
Returns TRUE if the last action caused an error.
void ErrorSnapshot(HSTMT statement = SQL_NULL_HSTMT)
This function will be called whenever an ODBC error occured. It stores the error related information returned by ODBC. If a statement handle of the concerning ODBC action is available it should be passed to the function.
wxString GetDatabaseName()
Returns the name of the database associated with the current connection.
wxString GetDataSource()
Returns the name of the connected data source.
wxString GetErrorClass()
Returns the error class of the last error. The error class consists of five characters where the first two characters contain the class and the other three characters contain the subclass of the ODBC error. See ODBC documentation for further details.
wxRETCODE GetErrorCode()
Returns the error code of the last ODBC function call. This will be one of:
SQL_ERROR | General error. |
SQL_INVALID_HANDLE | An invalid handle was passed to an ODBC function. |
SQL_NEED_DATA | ODBC expected some data. |
SQL_NO_DATA_FOUND | No data was found by this ODBC call. |
SQL_SUCCESS | The call was successful. |
SQL_SUCCESS_WITH_INFO | The call was successful, but further information can be obtained from the ODBC manager. |
wxString GetErrorMessage()
Returns the last error message returned by the ODBC manager.
long GetErrorNumber()
Returns the last native error. A native error is an ODBC driver dependent error number.
HDBC GetHDBC()
Returns the current ODBC database handle.
HENV GetHENV()
Returns the ODBC environment handle.
bool GetInfo(long infoType, long *buf)
bool GetInfo(long infoType, const wxString& buf, int bufSize=-1)
Returns requested information. The return value is TRUE if successful, FALSE otherwise.
infoType is an ODBC identifier specifying the type of information to be returned.
buf is a character or long integer pointer to storage which must be allocated by the application, and which will contain the information if the function is successful.
bufSize is the size of the character buffer. A value of -1 indicates that the size should be computed by the GetInfo function.
wxString GetPassword()
Returns the password of the current user.
wxString GetUsername()
Returns the current username.
float GetODBCVersionFloat(bool implementation=TRUE)
Returns the version of ODBC in floating point format, e.g. 2.50.
implementation should be TRUE to get the DLL version, or FALSE to get the version defined in the sql.h header file.
This function can return the value 0.0 if the header version number is not defined (for early versions of ODBC).
wxString GetODBCVersionString(bool implementation=TRUE)
Returns the version of ODBC in string format, e.g. "02.50".
implementation should be TRUE to get the DLL version, or FALSE to get the version defined in the sql.h header file.
This function can return the value "00.00" if the header version number is not defined (for early versions of ODBC).
bool InWaitForDataSource()
Not implemented.
bool IsOpen()
Returns TRUE if a connection is open.
bool Open(const wxString& datasource, bool exclusive = FALSE, bool readOnly = TRUE, const wxString& username = "ODBC", const wxString& password = "")
Connect to a data source. datasource contains the name of the ODBC data source. The parameters exclusive and readOnly are not used.
void OnSetOptions(wxRecordSet *recordSet)
Not implemented.
void OnWaitForDataSource(bool stillExecuting)
Not implemented.
bool RollbackTrans()
Sends a rollback to the ODBC driver. Not implemented.
void SetDataSource(const wxString& s)
Sets the name of the data source. Not implemented.
void SetLoginTimeout(long seconds)
Sets the time to wait for an user login. Not implemented.
void SetPassword(const wxString& s)
Sets the password of the current user. Not implemented.
void SetSynchronousMode(bool synchronous)
Toggles between synchronous and asynchronous mode. Currently only synchronous mode is supported, so this function has no effect.
void SetQueryTimeout(long seconds)
Sets the time to wait for a response to a query. Not implemented.
void SetUsername(const wxString& s)
Sets the name of the current user. Not implemented.