1 \section{\class{wxDatabase
}}\label{wxdatabase
}
3 Every database object represents an ODBC connection.
4 The connection may be closed and reopened.
6 \wxheading{Derived from
}
8 \helpref{wxObject
}{wxobject
}
10 \wxheading{Include files
}
16 \overview{wxDatabase overview
}{wxdatabaseoverview
},
\helpref{wxRecordSet
}{wxrecordset
}
18 A much more robust and feature-rich set of ODBC classes is now
19 available and recommended for use in place of the wxDatabase class.
21 See details of these classes in:
22 \helpref{wxDb
}{wxdb
},
\helpref{wxDbTable
}{wxdbtable
}
24 \latexignore{\rtfignore{\wxheading{Members
}}}
26 \membersection{wxDatabase::wxDatabase
}
28 \func{}{wxDatabase
}{\void}
30 Constructor. The constructor of the first wxDatabase instance of an
31 application initializes the ODBC manager.
33 \membersection{wxDatabase::
\destruct{wxDatabase
}}
35 \func{}{\destruct{wxDatabase
}}{\void}
37 Destructor. Resets and destroys any associated wxRecordSet instances.
39 The destructor of the last wxDatabase instance will deinitialize
42 \membersection{wxDatabase::BeginTrans
}
44 \func{bool
}{BeginTrans
}{\void}
48 \membersection{wxDatabase::Cancel
}
50 \func{void
}{Cancel
}{\void}
54 \membersection{wxDatabase::CanTransact
}
56 \func{bool
}{CanTransact
}{\void}
61 \membersection{wxDatabase::CanUpdate
}
63 \func{bool
}{CanUpdate
}{\void}
67 \membersection{wxDatabase::Close
}
69 \func{bool
}{Close
}{\void}
71 Resets the statement handles of any associated wxRecordSet objects,
72 and disconnects from the current data source.
74 \membersection{wxDatabase::CommitTrans
}
76 \func{bool
}{CommitTrans
}{\void}
78 Commits previous transactions. Not implemented.
80 \membersection{wxDatabase::GetDatabaseName
}
82 \func{wxString
}{GetDatabaseName
}{\void}
84 Returns the name of the database associated with the current connection.
86 \membersection{wxDatabase::GetDataSource
}
88 \func{wxString
}{GetDataSource
}{\void}
90 Returns the name of the connected data source.
92 \membersection{wxDatabase::GetErrorClass
}
94 \func{wxString
}{GetErrorClass
}{\void}
96 Returns the error class of the last error. The error class consists of
97 five characters where the first two characters contain the class
98 and the other three characters contain the subclass of the ODBC error.
99 See ODBC documentation for further details.
101 \membersection{wxDatabase::GetErrorCode
}
103 \func{wxRETCODE
}{GetErrorCode
}{\void}
105 Returns the error code of the last ODBC function call. This will be one of:
107 \begin{twocollist
}\itemsep=
0pt
108 \twocolitem{SQL
\_ERROR}{General error.
}
109 \twocolitem{SQL
\_INVALID\_HANDLE}{An invalid handle was passed to an ODBC function.
}
110 \twocolitem{SQL
\_NEED\_DATA}{ODBC expected some data.
}
111 \twocolitem{SQL
\_NO\_DATA\_FOUND}{No data was found by this ODBC call.
}
112 \twocolitem{SQL
\_SUCCESS}{The call was successful.
}
113 \twocolitem{SQL
\_SUCCESS\_WITH\_INFO}{The call was successful, but further information can be
114 obtained from the ODBC manager.
}
117 \membersection{wxDatabase::GetErrorMessage
}
119 \func{wxString
}{GetErrorMessage
}{\void}
121 Returns the last error message returned by the ODBC manager.
123 \membersection{wxDatabase::GetErrorNumber
}
125 \func{long
}{GetErrorNumber
}{\void}
127 Returns the last native error. A native error is an ODBC driver dependent
130 \membersection{wxDatabase::GetHDBC
}
132 \func{HDBC
}{GetHDBC
}{\void}
134 Returns the current ODBC database handle.
136 \membersection{wxDatabase::GetHENV
}
138 \func{HENV
}{GetHENV
}{\void}
140 Returns the ODBC environment handle.
142 \membersection{wxDatabase::GetInfo
}
144 \func{bool
}{GetInfo
}{\param{long
}{ infoType
},
\param{long *
}{buf
}}
146 \func{bool
}{GetInfo
}{\param{long
}{ infoType
},
\param{const wxString\&
}{buf
},
\param{int
}{ bufSize=-
1}}
148 Returns requested information. The return value is true if successful, false otherwise.
150 {\it infoType
} is an ODBC identifier specifying the type of information to be returned.
152 {\it buf
} is a character or long integer pointer to storage which must be allocated by the
153 application, and which will contain the information if the function is successful.
155 {\it bufSize
} is the size of the character buffer. A value of -
1 indicates that the size
156 should be computed by the GetInfo function.
158 \membersection{wxDatabase::GetPassword
}
160 \func{wxString
}{GetPassword
}{\void}
162 Returns the password of the current user.
164 \membersection{wxDatabase::GetUsername
}
166 \func{wxString
}{GetUsername
}{\void}
168 Returns the current username.
170 \membersection{wxDatabase::GetODBCVersionFloat
}
172 \func{float
}{GetODBCVersionFloat
}{\param{bool
}{ implementation=true
}}
174 Returns the version of ODBC in floating point format, e.g.
2.50.
176 {\it implementation
} should be true to get the DLL version, or false to get the
177 version defined in the
{\tt sql.h
} header file.
179 This function can return the value
0.0 if the header version number is not defined (for early
182 \membersection{wxDatabase::GetODBCVersionString
}
184 \func{wxString
}{GetODBCVersionString
}{\param{bool
}{ implementation=true
}}
186 Returns the version of ODBC in string format, e.g. ``
02.50".
188 {\it implementation
} should be true to get the DLL version, or false to get the
189 version defined in the
{\tt sql.h
} header file.
191 This function can return the value ``
00.00" if the header version number is not defined (for early
194 \membersection{wxDatabase::InWaitForDataSource
}
196 \func{bool
}{InWaitForDataSource
}{\void}
200 \membersection{wxDatabase::IsOpen
}
202 \func{bool
}{IsOpen
}{\void}
204 Returns true if a connection is open.
206 \membersection{wxDatabase::Open
}\label{wxdatabaseopen
}
208 \func{bool
}{Open
}{\param{const wxString\&
}{datasource
},
\param{bool
}{ exclusive = false
},
\param{bool
}{readOnly = true
},
209 \param{const wxString\&
}{username = ``ODBC"
},
\param{const wxString\&
}{password = ``"
}}
211 Connect to a data source.
{\it datasource
} contains the name of the ODBC data
212 source. The parameters exclusive and readOnly are not used.
214 \membersection{wxDatabase::OnSetOptions
}
216 \func{void
}{OnSetOptions
}{\param{wxRecordSet *
}{recordSet
}}
220 \membersection{wxDatabase::OnWaitForDataSource
}
222 \func{void
}{OnWaitForDataSource
}{\param{bool
}{ stillExecuting
}}
226 \membersection{wxDatabase::RollbackTrans
}
228 \func{bool
}{RollbackTrans
}{\void}
230 Sends a rollback to the ODBC driver. Not implemented.
232 \membersection{wxDatabase::SetDataSource
}
234 \func{void
}{SetDataSource
}{\param{const wxString\&
}{s
}}
236 Sets the name of the data source. Not implemented.
238 \membersection{wxDatabase::SetLoginTimeout
}
240 \func{void
}{SetLoginTimeout
}{\param{long
}{ seconds
}}
242 Sets the time to wait for an user login. Not implemented.
244 \membersection{wxDatabase::SetPassword
}
246 \func{void
}{SetPassword
}{\param{const wxString\&
}{s
}}
248 Sets the password of the current user. Not implemented.
250 \membersection{wxDatabase::SetSynchronousMode
}
252 \func{void
}{SetSynchronousMode
}{\param{bool
}{synchronous
}}
254 Toggles between synchronous and asynchronous mode. Currently only synchronous
255 mode is supported, so this function has no effect.
257 \membersection{wxDatabase::SetQueryTimeout
}
259 \func{void
}{SetQueryTimeout
}{\param{long
}{ seconds
}}
261 Sets the time to wait for a response to a query. Not implemented.
263 \membersection{wxDatabase::SetUsername
}
265 \func{void
}{SetUsername
}{\param{const wxString\&
}{s
}}
267 Sets the name of the current user. Not implemented.