Version: 1.0.0
wxTdsDatabase Class Reference

#include <tds_database.h>

+ Inheritance diagram for wxTdsDatabase:

Detailed Description

Definition at line 11 of file tds_database.h.

Classes

struct  status_t
 

Public Types

enum  {
  TDS_42 = 0, TDS_46, TDS_50, TDS_70,
  TDS_71, TDS_72, TDS_73, TDS_74,
  TDS_80
}
 

Public Member Functions

 wxTdsDatabase ()
 
 wxTdsDatabase (const wxString &strFreeTDS, const wxString &strServer, const wxString &strDatabase, const wxString &strUser, const wxString &strPassword, int nTdsVersion=TDS_80)
 
virtual ~wxTdsDatabase ()
 
virtual bool Open (const wxString &strDatabase)
 
bool Connect ()
 
virtual bool Close ()
 close database More...
 
virtual bool IsOpen ()
 Is the connection to the database open? More...
 
virtual void BeginTransaction ()
 Begin a transaction. More...
 
virtual void Commit ()
 Commit the current transaction. More...
 
virtual void RollBack ()
 Rollback the current transaction. More...
 
virtual int RunQuery (const wxString &strQuery, bool bParseQuery)
 Run an insert, update, or delete query on the database. More...
 
virtual wxDatabaseResultSetRunQueryWithResults (const wxString &strQuery)
 Run a select query on the database. More...
 
virtual wxPreparedStatementPrepareStatement (const wxString &strQuery)
 Prepare a SQL statement which can be reused with different parameters. More...
 
void SetFreeTDS (const wxString &strFreeTDS)
 
void SetServer (const wxString &strServer)
 
void SetDatabase (const wxString &strDatabase)
 
void SetLogin (const wxString &strLogin)
 
void SetPassword (const wxString &strPassword)
 
void SetTdsVersion (int nTdsVersion)
 
virtual bool TableExists (const wxString &table)
 Check for the existence of a table by name. More...
 
virtual bool ViewExists (const wxString &view)
 Check for the existence of a view by name. More...
 
virtual wxArrayString GetTables ()
 Retrieve all table names. More...
 
virtual wxArrayString GetViews ()
 Retrieve all view names. More...
 
virtual wxArrayString GetColumns (const wxString &table)
 Retrieve all column names for a table. More...
 
virtual wxArrayString GetPKColumns (const wxString &table)
 get Primary keys column names More...
 
void SetError (int nCode, const wxString &strMessage)
 
- Public Member Functions inherited from wxDatabase
 wxDatabase ()
 Constructor. More...
 
virtual ~wxDatabase ()
 Destructor. More...
 
virtual bool ChangeDatabase (const wxString &database)
 
virtual int RunQuery (const wxString &strQuery)
 Run an insert, update, or delete query on the database. More...
 
virtual bool CloseResultSet (wxDatabaseResultSet *pResultSet)
 Close a result set returned by the database or a prepared statement previously. More...
 
virtual bool CloseStatement (wxPreparedStatement *pStatement)
 Close a prepared statement previously prepared by the database. More...
 
int ExecuteUpdate (const wxString &strQuery)
 See RunQuery. More...
 
wxDatabaseResultSetExecuteQuery (const wxString &strQuery)
 See RunQueryWithResults. More...
 
virtual int GetSingleResultInt (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 With the GetSingleResultX API, two additional exception types are thrown: wxDATABASE_NO_ROWS_FOUND - No database rows were returned wxDATABASE_NON_UNIQUE_RESULTSET - More than one database row was returned. More...
 
virtual int GetSingleResultInt (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual wxString GetSingleResultString (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single string value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual wxString GetSingleResultString (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual long GetSingleResultLong (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single long value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual long GetSingleResultLong (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual bool GetSingleResultBool (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single bool value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual bool GetSingleResultBool (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual wxDateTime GetSingleResultDate (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single date/time value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual wxDateTime GetSingleResultDate (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual void * GetSingleResultBlob (const wxString &strSQL, int nField, wxMemoryBuffer &Buffer, bool bRequireUniqueResult=true)
 Retrieve a single Blob value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual void * GetSingleResultBlob (const wxString &strSQL, const wxString &strField, wxMemoryBuffer &Buffer, bool bRequireUniqueResult=true)
 
virtual double GetSingleResultDouble (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single double value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual double GetSingleResultDouble (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual wxArrayInt GetResultsArrayInt (const wxString &strSQL, int nField)
 Retrieve all the values of one field in a result set. More...
 
virtual wxArrayInt GetResultsArrayInt (const wxString &strSQL, const wxString &Field)
 
virtual wxArrayString GetResultsArrayString (const wxString &strSQL, int nField)
 
virtual wxArrayString GetResultsArrayString (const wxString &strSQL, const wxString &Field)
 
virtual wxArrayLong GetResultsArrayLong (const wxString &strSQL, int nField)
 
virtual wxArrayLong GetResultsArrayLong (const wxString &strSQL, const wxString &Field)
 
virtual wxArrayDouble GetResultsArrayDouble (const wxString &strSQL, int nField)
 
virtual wxArrayDouble GetResultsArrayDouble (const wxString &strSQL, const wxString &Field)
 
void CloseResultSets ()
 Close all result set objects that have been generated but not yet closed. More...
 
void CloseStatements ()
 Close all prepared statement objects that have been generated but not yet closed. More...
 
const wxString & GetTypeName ()
 Get a descriptive name for the type of database. More...
 
bool IsViaODBC ()
 Is the connection via ODBC. More...
 
const wxString & GetLibraryPath ()
 Get the library path required by the database. More...
 
- Public Member Functions inherited from wxDatabaseErrorReporter
 wxDatabaseErrorReporter ()
 
virtual ~wxDatabaseErrorReporter ()
 
const wxString & GetErrorMessage ()
 
int GetErrorCode ()
 
void ResetErrorCodes ()
 
- Public Member Functions inherited from wxDatabaseStringConverter
 wxDatabaseStringConverter ()
 
 wxDatabaseStringConverter (const wxChar *charset)
 
virtual ~wxDatabaseStringConverter ()
 
void SetEncoding (wxFontEncoding encoding)
 
void SetEncoding (const wxCSConv *conv)
 
const wxCSConv * GetEncoding ()
 
virtual const wxCharBuffer ConvertToUnicodeStream (const wxString &inputString)
 
virtual size_t GetEncodedStreamLength (const wxString &inputString)
 
virtual wxString ConvertFromUnicodeStream (const char *inputBuffer)
 
virtual wxString ConvertFromUnicodeStream (const wxChar *inputBuffer)
 

Static Public Member Functions

static wxTdsDatabaseLookupTdsLayer (const TDSCONTEXT *pContext)
 
- Static Public Member Functions inherited from wxDatabase
static wxDatabaseGetDatabase (wxConfigBase &config, wxString *err=NULL, const wxString &path="/")
 Get an instance of the first valid database specified in config. More...
 
- Static Public Member Functions inherited from wxDatabaseStringConverter
static const wxCharBuffer ConvertToUnicodeStream (const wxString &inputString, const char *encoding)
 
static wxString ConvertFromUnicodeStream (const char *inputBuffer, const char *encoding)
 
static size_t GetEncodedStreamLength (const wxString &inputString, const char *encoding)
 
static wxString ConvertFromUnicodeStream (const wxChar *inputBuffer, const char *encoding)
 

Private Member Functions

void FreeAllocatedResultSets (status_t *status=NULL)
 
TDSPARAMINFO * GetParameters (const wxString &strQuery)
 

Static Private Member Functions

static int TranslateErrorCode (int nCode)
 
static void AddTdsLayer (TDSCONTEXT *pContext, wxTdsDatabase *pLayer)
 
static void RemoveTdsLayer (TDSCONTEXT *pContext)
 

Private Attributes

wxString m_strFreeTDS
 
wxString m_strServer
 
wxString m_strDatabase
 
wxString m_strLogin
 
wxString m_strPassword
 
int m_nTdsVersion
 
TDSSOCKET * m_pDatabase
 
TDSLOGIN * m_pLogin
 
TDSCONTEXT * m_pContext
 

Static Private Attributes

static TdsContextToDatabaseLayerMap m_ContextLookupMap
 

Additional Inherited Members

- Protected Member Functions inherited from wxDatabase
void LogResultSetForCleanup (wxDatabaseResultSet *pResultSet)
 Add result set object pointer to the list for "garbage collection". More...
 
void LogStatementForCleanup (wxPreparedStatement *pStatement)
 Add prepared statement object pointer to the list for "garbage collection". More...
 
- Protected Member Functions inherited from wxDatabaseErrorReporter
void SetErrorMessage (const wxString &strErrorMessage)
 
void SetErrorCode (int nErrorCode)
 
void ThrowDatabaseException ()
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TDS_42 
TDS_46 
TDS_50 
TDS_70 
TDS_71 
TDS_72 
TDS_73 
TDS_74 
TDS_80 

Definition at line 51 of file tds_database.h.

Constructor & Destructor Documentation

◆ wxTdsDatabase() [1/2]

wxTdsDatabase::wxTdsDatabase ( )

◆ wxTdsDatabase() [2/2]

wxTdsDatabase::wxTdsDatabase ( const wxString &  strFreeTDS,
const wxString &  strServer,
const wxString &  strDatabase,
const wxString &  strUser,
const wxString &  strPassword,
int  nTdsVersion = TDS_80 
)

◆ ~wxTdsDatabase()

virtual wxTdsDatabase::~wxTdsDatabase ( )
virtual

Member Function Documentation

◆ AddTdsLayer()

static void wxTdsDatabase::AddTdsLayer ( TDSCONTEXT *  pContext,
wxTdsDatabase pLayer 
)
staticprivate

◆ BeginTransaction()

virtual void wxTdsDatabase::BeginTransaction ( )
virtual

Begin a transaction.

Implements wxDatabase.

◆ Close()

virtual bool wxTdsDatabase::Close ( )
virtual

close database

Implements wxDatabase.

◆ Commit()

virtual void wxTdsDatabase::Commit ( )
virtual

Commit the current transaction.

Implements wxDatabase.

◆ Connect()

bool wxTdsDatabase::Connect ( )

◆ FreeAllocatedResultSets()

void wxTdsDatabase::FreeAllocatedResultSets ( status_t status = NULL)
private

◆ GetColumns()

virtual wxArrayString wxTdsDatabase::GetColumns ( const wxString &  table)
virtual

Retrieve all column names for a table.

Implements wxDatabase.

◆ GetParameters()

TDSPARAMINFO* wxTdsDatabase::GetParameters ( const wxString &  strQuery)
private

◆ GetPKColumns()

virtual wxArrayString wxTdsDatabase::GetPKColumns ( const wxString &  table)
virtual

get Primary keys column names

Implements wxDatabase.

◆ GetTables()

virtual wxArrayString wxTdsDatabase::GetTables ( )
virtual

Retrieve all table names.

Implements wxDatabase.

◆ GetViews()

virtual wxArrayString wxTdsDatabase::GetViews ( )
virtual

Retrieve all view names.

Implements wxDatabase.

◆ IsOpen()

virtual bool wxTdsDatabase::IsOpen ( )
virtual

Is the connection to the database open?

Implements wxDatabase.

◆ LookupTdsLayer()

static wxTdsDatabase* wxTdsDatabase::LookupTdsLayer ( const TDSCONTEXT *  pContext)
static

◆ Open()

virtual bool wxTdsDatabase::Open ( const wxString &  strDatabase)
virtual

Implements wxDatabase.

◆ PrepareStatement()

virtual wxPreparedStatement* wxTdsDatabase::PrepareStatement ( const wxString &  strQuery)
virtual

Prepare a SQL statement which can be reused with different parameters.

Implements wxDatabase.

◆ RemoveTdsLayer()

static void wxTdsDatabase::RemoveTdsLayer ( TDSCONTEXT *  pContext)
staticprivate

◆ RollBack()

virtual void wxTdsDatabase::RollBack ( )
virtual

Rollback the current transaction.

Implements wxDatabase.

◆ RunQuery()

virtual int wxTdsDatabase::RunQuery ( const wxString &  strQuery,
bool  bParseQueries 
)
virtual

Run an insert, update, or delete query on the database.

Implements wxDatabase.

◆ RunQueryWithResults()

virtual wxDatabaseResultSet* wxTdsDatabase::RunQueryWithResults ( const wxString &  strQuery)
virtual

Run a select query on the database.

Implements wxDatabase.

◆ SetDatabase()

void wxTdsDatabase::SetDatabase ( const wxString &  strDatabase)
inline

Definition at line 46 of file tds_database.h.

◆ SetError()

void wxTdsDatabase::SetError ( int  nCode,
const wxString &  strMessage 
)

◆ SetFreeTDS()

void wxTdsDatabase::SetFreeTDS ( const wxString &  strFreeTDS)
inline

Definition at line 44 of file tds_database.h.

◆ SetLogin()

void wxTdsDatabase::SetLogin ( const wxString &  strLogin)
inline

Definition at line 47 of file tds_database.h.

◆ SetPassword()

void wxTdsDatabase::SetPassword ( const wxString &  strPassword)
inline

Definition at line 48 of file tds_database.h.

◆ SetServer()

void wxTdsDatabase::SetServer ( const wxString &  strServer)
inline

Definition at line 45 of file tds_database.h.

◆ SetTdsVersion()

void wxTdsDatabase::SetTdsVersion ( int  nTdsVersion)
inline

Definition at line 49 of file tds_database.h.

◆ TableExists()

virtual bool wxTdsDatabase::TableExists ( const wxString &  table)
virtual

Check for the existence of a table by name.

Implements wxDatabase.

◆ TranslateErrorCode()

static int wxTdsDatabase::TranslateErrorCode ( int  nCode)
staticprivate

◆ ViewExists()

virtual bool wxTdsDatabase::ViewExists ( const wxString &  view)
virtual

Check for the existence of a view by name.

Implements wxDatabase.

Member Data Documentation

◆ m_ContextLookupMap

TdsContextToDatabaseLayerMap wxTdsDatabase::m_ContextLookupMap
staticprivate

Definition at line 93 of file tds_database.h.

◆ m_nTdsVersion

int wxTdsDatabase::m_nTdsVersion
private

Definition at line 100 of file tds_database.h.

◆ m_pContext

TDSCONTEXT* wxTdsDatabase::m_pContext
private

Definition at line 104 of file tds_database.h.

◆ m_pDatabase

TDSSOCKET* wxTdsDatabase::m_pDatabase
private

Definition at line 102 of file tds_database.h.

◆ m_pLogin

TDSLOGIN* wxTdsDatabase::m_pLogin
private

Definition at line 103 of file tds_database.h.

◆ m_strDatabase

wxString wxTdsDatabase::m_strDatabase
private

Definition at line 97 of file tds_database.h.

◆ m_strFreeTDS

wxString wxTdsDatabase::m_strFreeTDS
private

Definition at line 95 of file tds_database.h.

◆ m_strLogin

wxString wxTdsDatabase::m_strLogin
private

Definition at line 98 of file tds_database.h.

◆ m_strPassword

wxString wxTdsDatabase::m_strPassword
private

Definition at line 99 of file tds_database.h.

◆ m_strServer

wxString wxTdsDatabase::m_strServer
private

Definition at line 96 of file tds_database.h.