Version: 1.0.0
odbc_inteface.cpp
Go to the documentation of this file.
1 #include "wx/database/wxprec.h"
2 
3 #if wxUSE_DATABASE_ODBC
4 
6 {
7  // If Windows, then default to odbc32 and try odbc second
8  // Otherwise try odbc first and try odbc32 second
9 #ifdef __WIN32__
10  bool bLoaded = m_OdbcDLL.Load(wxDynamicLibrary::CanonicalizeName(wxT("odbc32")));
11 #else
12  bool bLoaded = m_OdbcDLL.Load(wxDynamicLibrary::CanonicalizeName(wxT("odbc")));
13 #endif
14  if (!bLoaded)
15  {
16 #ifdef __WIN32__
17  bLoaded = m_OdbcDLL.Load(wxDynamicLibrary::CanonicalizeName(wxT("odbc")));
18 #else
19  bLoaded = m_OdbcDLL.Load(wxDynamicLibrary::CanonicalizeName(wxT("odbc32")));
20 #endif
21  if (!bLoaded)
22  return false;
23  }
24 
25  wxString symbol = wxT("SQLAllocHandle");
26  if (m_OdbcDLL.HasSymbol(symbol))
27  {
28  m_pSQLAllocHandle = (SQLAllocHandleType)m_OdbcDLL.GetSymbol(symbol);
29  }
30  else
31  {
32  return false;
33  }
34 
35  symbol = wxT("SQLSetEnvAttr");
36  if (m_OdbcDLL.HasSymbol(symbol))
37  {
38  m_pSQLSetEnvAttr = (SQLSetEnvAttrType)m_OdbcDLL.GetSymbol(symbol);
39  }
40  else
41  {
42  return false;
43  }
44 
45  symbol = wxT("SQLFreeHandle");
46  if (m_OdbcDLL.HasSymbol(symbol))
47  {
48  m_pSQLFreeHandle = (SQLFreeHandleType)m_OdbcDLL.GetSymbol(symbol);
49  }
50  else
51  {
52  return false;
53  }
54 
55  symbol = wxT("SQLConnect");
56  if (m_OdbcDLL.HasSymbol(symbol))
57  {
58  m_pSQLConnect = (SQLConnectType)m_OdbcDLL.GetSymbol(symbol);
59  }
60  else
61  {
62  return false;
63  }
64 
65  symbol = wxT("SQLDriverConnect");
66  if (m_OdbcDLL.HasSymbol(symbol))
67  {
69  }
70  else
71  {
72  return false;
73  }
74 
75  symbol = wxT("SQLDisconnect");
76  if (m_OdbcDLL.HasSymbol(symbol))
77  {
78  m_pSQLDisconnect = (SQLDisconnectType)m_OdbcDLL.GetSymbol(symbol);
79  }
80  else
81  {
82  return false;
83  }
84 
85  symbol = wxT("SQLSetConnectAttr");
86  if (m_OdbcDLL.HasSymbol(symbol))
87  {
89  }
90  else
91  {
92  return false;
93  }
94 
95  symbol = wxT("SQLEndTran");
96  if (m_OdbcDLL.HasSymbol(symbol))
97  {
98  m_pSQLEndTran = (SQLEndTranType)m_OdbcDLL.GetSymbol(symbol);
99  }
100  else
101  {
102  return false;
103  }
104 
105  symbol = wxT("SQLPrepare");
106  if (m_OdbcDLL.HasSymbol(symbol))
107  {
108  m_pSQLPrepare = (SQLPrepareType)m_OdbcDLL.GetSymbol(symbol);
109  }
110  else
111  {
112  return false;
113  }
114 
115  symbol = wxT("SQLFreeStmt");
116  if (m_OdbcDLL.HasSymbol(symbol))
117  {
118  m_pSQLFreeStmt = (SQLFreeStmtType)m_OdbcDLL.GetSymbol(symbol);
119  }
120  else
121  {
122  return false;
123  }
124 
125  symbol = wxT("SQLTables");
126  if (m_OdbcDLL.HasSymbol(symbol))
127  {
128  m_pSQLTables = (SQLTablesType)m_OdbcDLL.GetSymbol(symbol);
129  }
130  else
131  {
132  return false;
133  }
134 
135  symbol = wxT("SQLFetch");
136  if (m_OdbcDLL.HasSymbol(symbol))
137  {
138  m_pSQLFetch = (SQLFetchType)m_OdbcDLL.GetSymbol(symbol);
139  }
140  else
141  {
142  return false;
143  }
144 
145  symbol = wxT("SQLGetData");
146  if (m_OdbcDLL.HasSymbol(symbol))
147  {
148  m_pSQLGetData = (SQLGetDataType)m_OdbcDLL.GetSymbol(symbol);
149  }
150  else
151  {
152  return false;
153  }
154 
155  symbol = wxT("SQLColumns");
156  if (m_OdbcDLL.HasSymbol(symbol))
157  {
158  m_pSQLColumns = (SQLColumnsType)m_OdbcDLL.GetSymbol(symbol);
159  }
160  else
161  {
162  return false;
163  }
164 
165  symbol = wxT("SQLPrimaryKeys");
166  if (m_OdbcDLL.HasSymbol(symbol))
167  {
168  m_pSQLPKColumns = (SQLColumnsType)m_OdbcDLL.GetSymbol(symbol); // AML
169  }
170  else
171  {
172  return false;
173  }
174 
175  symbol = wxT("SQLGetDiagRec");
176  if (m_OdbcDLL.HasSymbol(symbol))
177  {
178  m_pSQLGetDiagRec = (SQLGetDiagRecType)m_OdbcDLL.GetSymbol(symbol);
179  }
180  else
181  {
182  return false;
183  }
184 
185  symbol = wxT("SQLNumParams");
186  if (m_OdbcDLL.HasSymbol(symbol))
187  {
188  m_pSQLNumParams = (SQLNumParamsType)m_OdbcDLL.GetSymbol(symbol);
189  }
190  else
191  {
192  return false;
193  }
194 
195  symbol = wxT("SQLExecute");
196  if (m_OdbcDLL.HasSymbol(symbol))
197  {
198  m_pSQLExecute = (SQLExecuteType)m_OdbcDLL.GetSymbol(symbol);
199  }
200  else
201  {
202  return false;
203  }
204 
205  symbol = wxT("SQLParamData");
206  if (m_OdbcDLL.HasSymbol(symbol))
207  {
208  m_pSQLParamData = (SQLParamDataType)m_OdbcDLL.GetSymbol(symbol);
209  }
210  else
211  {
212  return false;
213  }
214 
215  symbol = wxT("SQLPutData");
216  if (m_OdbcDLL.HasSymbol(symbol))
217  {
218  m_pSQLPutData = (SQLPutDataType)m_OdbcDLL.GetSymbol(symbol);
219  }
220  else
221  {
222  return false;
223  }
224 
225  symbol = wxT("SQLRowCount");
226  if (m_OdbcDLL.HasSymbol(symbol))
227  {
228  m_pSQLRowCount = (SQLRowCountType)m_OdbcDLL.GetSymbol(symbol);
229  }
230  else
231  {
232  return false;
233  }
234 
235  symbol = wxT("SQLNumResultCols");
236  if (m_OdbcDLL.HasSymbol(symbol))
237  {
239  }
240  else
241  {
242  return false;
243  }
244 
245  symbol = wxT("SQLDescribeParam");
246  if (m_OdbcDLL.HasSymbol(symbol))
247  {
249  }
250  else
251  {
252  return false;
253  }
254 
255  symbol = wxT("SQLBindParameter");
256  if (m_OdbcDLL.HasSymbol(symbol))
257  {
259  }
260  else
261  {
262  return false;
263  }
264 
265  symbol = wxT("SQLColAttributes");
266  if (m_OdbcDLL.HasSymbol(symbol))
267  {
269  }
270  else
271  {
272  return false;
273  }
274 
275  symbol = wxT("SQLColAttribute");
276  if (m_OdbcDLL.HasSymbol(symbol))
277  {
278  m_pSQLColAttribute = (SQLColAttributeType)m_OdbcDLL.GetSymbol(symbol);
279  }
280  else
281  {
282  return false;
283  }
284 
285  symbol = wxT("SQLDescribeCol");
286  if (m_OdbcDLL.HasSymbol(symbol))
287  {
288  m_pSQLDescribeCol = (SQLDescribeColType)m_OdbcDLL.GetSymbol(symbol);
289  }
290  else
291  {
292  return false;
293  }
294 
295  return true;
296 }
297 
298 #endif//wxUSE_DATABASE_ODBC
SQLDescribeParamType m_pSQLDescribeParam
SQLExecuteType m_pSQLExecute
SQLDescribeColType m_pSQLDescribeCol
SQLRETURN(SQL_API * SQLConnectType)(SQLHDBC, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT)
Definition: odbc_inteface.h:11
SQLBindParameterType m_pSQLBindParameter
SQLGetDataType m_pSQLGetData
Definition: odbc_inteface.h:96
SQLSetEnvAttrType m_pSQLSetEnvAttr
Definition: odbc_inteface.h:85
SQLFetchType m_pSQLFetch
Definition: odbc_inteface.h:95
SQLRETURN(SQL_API * SQLColAttributesType)(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT *, SQLLEN *)
Definition: odbc_inteface.h:39
SQLFreeStmtType m_pSQLFreeStmt
Definition: odbc_inteface.h:93
SQLRETURN(SQL_API * SQLGetDataType)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN *)
Definition: odbc_inteface.h:23
SQLNumParamsType m_pSQLNumParams
SQLRETURN(SQL_API * SQLNumResultColsType)(SQLHSTMT, SQLSMALLINT *)
Definition: odbc_inteface.h:34
SQLRETURN(SQL_API * SQLTablesType)(SQLHSTMT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT)
Definition: odbc_inteface.h:20
SQLRETURN(SQL_API * SQLPrepareType)(SQLHSTMT, SQLTCHAR *, SQLINTEGER)
Definition: odbc_inteface.h:18
SQLRETURN(SQL_API * SQLDisconnectType)(SQLHDBC)
Definition: odbc_inteface.h:15
SQLRETURN(SQL_API * SQLEndTranType)(SQLSMALLINT, SQLHANDLE, SQLSMALLINT)
Definition: odbc_inteface.h:17
SQLDisconnectType m_pSQLDisconnect
Definition: odbc_inteface.h:89
SQLSetConnectAttrType m_pSQLSetConnectAttr
Definition: odbc_inteface.h:90
SQLColumnsType m_pSQLPKColumns
Definition: odbc_inteface.h:98
SQLRETURN(SQL_API * SQLFreeStmtType)(SQLHSTMT, SQLUSMALLINT)
Definition: odbc_inteface.h:19
SQLPutDataType m_pSQLPutData
SQLTablesType m_pSQLTables
Definition: odbc_inteface.h:94
SQLRETURN(SQL_API * SQLDescribeParamType)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT *, SQLULEN *, SQLSMALLINT *, SQLSMALLINT *)
Definition: odbc_inteface.h:35
SQLConnectType m_pSQLConnect
Definition: odbc_inteface.h:87
SQLRETURN(SQL_API * SQLExecuteType)(SQLHSTMT)
Definition: odbc_inteface.h:30
SQLRETURN(SQL_API * SQLRowCountType)(SQLHSTMT, SQLLEN *)
Definition: odbc_inteface.h:33
SQLRETURN(SQL_API * SQLFreeHandleType)(SQLSMALLINT, SQLHANDLE)
Definition: odbc_inteface.h:10
SQLGetDiagRecType m_pSQLGetDiagRec
Definition: odbc_inteface.h:99
SQLRETURN(SQL_API * SQLDescribeColType)(SQLHSTMT, SQLUSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLSMALLINT *, SQLSMALLINT *, SQLULEN *, SQLSMALLINT *, SQLSMALLINT *)
Definition: odbc_inteface.h:43
SQLRETURN(SQL_API * SQLPutDataType)(SQLHSTMT, SQLPOINTER, SQLLEN)
Definition: odbc_inteface.h:32
SQLColumnsType m_pSQLColumns
Definition: odbc_inteface.h:97
SQLRETURN(SQL_API * SQLGetDiagRecType)(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLTCHAR *, SQLINTEGER *, SQLTCHAR *, SQLSMALLINT, SQLSMALLINT *)
Definition: odbc_inteface.h:27
SQLColAttributesType m_pSQLColAttributes
SQLRETURN(SQL_API * SQLColAttributeType)(SQLHSTMT, SQLUSMALLINT, SQLUSMALLINT, SQLPOINTER, SQLSMALLINT, SQLSMALLINT *, SQLPOINTER)
Definition: odbc_inteface.h:41
SQLParamDataType m_pSQLParamData
SQLRETURN(SQL_API * SQLNumParamsType)(SQLHSTMT, SQLSMALLINT *)
Definition: odbc_inteface.h:29
SQLAllocHandleType m_pSQLAllocHandle
Definition: odbc_inteface.h:84
wxDynamicLibrary m_OdbcDLL
Definition: odbc_inteface.h:82
SQLRETURN(SQL_API * SQLAllocHandleType)(SQLSMALLINT, SQLHANDLE, SQLHANDLE *)
Definition: odbc_inteface.h:8
SQLRETURN(SQL_API * SQLFetchType)(SQLHSTMT)
Definition: odbc_inteface.h:22
SQLRETURN(SQL_API * SQLSetEnvAttrType)(SQLHENV, SQLINTEGER, SQLPOINTER, SQLINTEGER)
Definition: odbc_inteface.h:9
SQLRETURN(SQL_API * SQLColumnsType)(SQLHSTMT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT)
Definition: odbc_inteface.h:25
SQLColAttributeType m_pSQLColAttribute
SQLFreeHandleType m_pSQLFreeHandle
Definition: odbc_inteface.h:86
SQLPrepareType m_pSQLPrepare
Definition: odbc_inteface.h:92
SQLRETURN(SQL_API * SQLParamDataType)(SQLHSTMT, SQLPOINTER *)
Definition: odbc_inteface.h:31
SQLRETURN(SQL_API * SQLBindParameterType)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLULEN, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN *)
Definition: odbc_inteface.h:37
SQLRowCountType m_pSQLRowCount
SQLRETURN(SQL_API * SQLDriverConnectType)(SQLHDBC, SQLHWND, SQLTCHAR *, SQLSMALLINT, SQLTCHAR *, SQLSMALLINT, SQLSMALLINT *, SQLUSMALLINT)
Definition: odbc_inteface.h:13
SQLEndTranType m_pSQLEndTran
Definition: odbc_inteface.h:91
SQLDriverConnectType m_pSQLDriverConnect
Definition: odbc_inteface.h:88
SQLRETURN(SQL_API * SQLSetConnectAttrType)(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER)
Definition: odbc_inteface.h:16
SQLNumResultColsType m_pSQLNumResultCols