Version: 1.0.0
odbc_database.h
Go to the documentation of this file.
1 #ifndef _WX_DATABASE_ODBC_H_
2 #define _WX_DATABASE_ODBC_H_
3 
4 #include "wx/database/wxprec.h"
5 
6 class wxOdbcInterface;
7 
8 #define ERR_BUFFER_LEN 1024
9 #define ERR_STATE_LEN 10
10 
11 
13 {
14 public:
15  // ctor()
17 
18  // dtor()
19  virtual ~wxOdbcDatabase();
20 
21  // open database
22  virtual bool Open();
23  virtual bool Open(const wxString& strConnection);
24  virtual bool Open(const wxString& strDSN, const wxString& strUser, const wxString& strPassword);
25 #if wxUSE_GUI
26  virtual bool Open(const wxString& strConnection, bool bPromptForInfo, wxWindow* parent = NULL);
27 #endif
28 
29  // close database
30  virtual bool Close();
31 
32  // Is the connection to the database open?
33  virtual bool IsOpen();
34 
35  // transaction support
36  virtual void BeginTransaction();
37  virtual void Commit();
38  virtual void RollBack();
39 
40  // query database
41  virtual int RunQuery(const wxString& strQuery, bool bParseQuery);
42  virtual wxDatabaseResultSet* RunQueryWithResults(const wxString& strQuery);
43 
44  // wxPreparedStatement support
45  virtual wxPreparedStatement* PrepareStatement(const wxString& strQuery);
46 
47  // Database schema API contributed by M. Szeftel (author of wxActiveRecordGenerator)
48  virtual bool TableExists(const wxString& table);
49  virtual bool ViewExists(const wxString& view);
50  virtual wxArrayString GetTables();
51  virtual wxArrayString GetViews();
52  virtual wxArrayString GetColumns(const wxString& table);
53  virtual wxArrayString GetPKColumns(const wxString& table);
54 
55  static bool IsAvailable();
56 
57 private:
58  virtual wxPreparedStatement* PrepareStatement(const wxString& strQuery, bool bParseQuery);
59 
60  //SQLHENV m_sqlEnvHandle;
62  //SQLHDBC m_sqlHDBC;
63  void* m_sqlHDBC;
64 
65  wxString m_strDSN;
66  wxString m_strUser;
67  wxString m_strPassword;
68 
69  wxString m_strConnection;
70 #if wxUSE_GUI
71  bool m_bPrompt;
72  wxWindow* m_pParent;
73 #endif
74 
77 
78 public:
79 
80  // error handling
81  //void InterpretErrorCodes( long nCode, SQLHSTMT stmth_ptr = NULL );
82  void InterpretErrorCodes( long nCode, void* stmth_ptr = NULL );
83 
84  //SQLHANDLE allocStmth();
85  void* allocStmth();
86 };
87 
88 #endif//_WX_DATABASE_ODBC_H_
89 
virtual wxArrayString GetPKColumns(const wxString &table)=0
get Primary keys column names
virtual wxArrayString GetViews()=0
Retrieve all view names.
wxOdbcInterface * m_pInterface
Definition: odbc_database.h:76
wxString m_strConnection
Definition: odbc_database.h:69
virtual wxPreparedStatement * PrepareStatement(const wxString &strQuery)=0
Prepare a SQL statement which can be reused with different parameters.
wxString m_strDSN
Definition: odbc_database.h:65
wxString m_strPassword
Definition: odbc_database.h:67
virtual void RollBack()=0
Rollback the current transaction.
virtual bool IsOpen()=0
Is the connection to the database open?
wxString m_strUser
Definition: odbc_database.h:66
virtual int RunQuery(const wxString &strQuery)
Run an insert, update, or delete query on the database.
Definition: database.cpp:19
virtual void BeginTransaction()=0
Begin a transaction.
virtual bool Open(const wxString &strDatabase)=0
virtual bool ViewExists(const wxString &view)=0
Check for the existence of a view by name.
void * m_sqlEnvHandle
Definition: odbc_database.h:61
virtual void Commit()=0
Commit the current transaction.
virtual wxArrayString GetColumns(const wxString &table)=0
Retrieve all column names for a table.
virtual bool Close()=0
close database
virtual bool TableExists(const wxString &table)=0
Check for the existence of a table by name.
#define WXDLLIMPEXP_DATABASE
virtual wxArrayString GetTables()=0
Retrieve all table names.
virtual wxDatabaseResultSet * RunQueryWithResults(const wxString &strQuery)=0
Run a select query on the database.