⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
📖 第 1 页 / 共 5 页
字号:
Normally the first form of the wxDb::Open() function will open the connectionand then send a series of queries to the datasource asking it for itsrepresentation of data types, and all the features it supports.  If oneconnection to the datasource has already been made previously, the informationgathered when that connection was created can just be copied to any newconnections to the same datasource by passing a pointer to the firstconnection in as a parameter to the wxDb::Open() function.  Note that thisnew connection created from the first connections information will use thesame Dsn/Uid/AuthStr as the first connection used.\wxheading{Parameters}\docparam{Dsn}{datasource name.  The name of the ODBC datasource asassigned when the datasource is initially set up through the ODBC datasource manager.}\docparam{Uid}{User ID.  The name (ID) of the user you wish to connect asto the datasource.  The user name (ID) determines what objects youhave access to in the datasource and what datasource privileges you have.Privileges include being able to create new objects, update objects, deleteobjects and so on.  Users and privileges are normally administered by thedatabase administrator.}\docparam{AuthStr}{The password associated with the Uid.}\docparam{failOnDataTypeUnsupporte}{As part of connecting to a database, the wxDb::Open() function will query the database to find out the native types that it supports.  With some databases, some data types may not be supported,or not sufficiently supported, for use with the wxODBC classes.  Normallya program should fail in this case, so as not to try to use a data typethat is not supported.  This parameter allows the programmer to override thefailure if they wish and continue on using the connection.}\docparam{dbConnectInf}{Contains a DSN, Uid, Password, or a connection string to be used in opening a new connection to the database.  If a connectionstring is present, then the connection string will be used.  If there is no connection string present, then the DSN, Uid, and Password are used.}\docparam{inConnectStr}{A valid ODBC connection string used to connect to a database}\docparam{copyDb}{Already completely configured and opened datasource connection from which all Dsn, Uid, AuthStr, connection string, and data typing information is to be copied from for use by this datasource connection.  If 'copyDb' used a connection string to create its connection originally, then the connection being made by this call to wxDb::Open() will use that same connection string.}\wxheading{Remarks}After a wxDb instance is created, it must then be opened.  When opening adatasource, there must be three pieces of information passed.  The datasource name, user name (ID) and the password for the user.  No databaseactivity on the datasource can be performed until the connection is opened.This is normally done at program startup and the datasource remainsopen for the duration of the program/module run.It is possible to have connections to multiple datasources open at the sametime to support distributed database connections by having separate instancesof wxDb objects that use either the same or different Dsn/Uid/AuthStr settings.If this function returns a value of false, it does not necessarily mean thatthe connection to the datasource was not opened.  It may mean that someportion of the initialization of the connection failed (such as a datatype notbeing able to be determined how the datasource represents it).  To determineif the connection to the database failed, use the \helpref{wxDb::IsOpen}{wxdbisopen}function after receiving a false result back from this function to determine ifthe connection was opened or not.  If this function returns false, but \helpref{wxDb::IsOpen}{wxdbisopen}returns true, then direct SQL commands may be passed to the databaseconnection and can be successfully executed, but use of the datatypes (such asby a wxDbTable instance) that are normally determined during open will not bepossible.\normalbox{The {\it Dsn}, {\it Uid}, and {\it AuthStr} string pointers that are passed inare copied.  NOT the strings themselves, only the pointers.  The calling routinemust maintain the memory for these three strings for the life of the wxDb instance.}\wxheading{Example}\begin{verbatim}   wxDb sampleDB(DbConnectInf.GetHenv());   if (!sampleDB.Open("Oracle 7.1 HP/UX", "gtasker", "myPassword"))   {      if (sampleDb.IsOpen())      {        // Connection is open, but the initialization of        // datatypes and parameter settings failed      }      else      {        // Error opening datasource      }   }\end{verbatim}\membersection{wxDb::RollbackTrans}\label{wxdbrollbacktrans}\func{bool}{RollbackTrans}{\void}Function to "undo" changes made to the database.  After an insert/update/delete, the operation may be "undone" by issuing this command any time before a \helpref{wxDb::CommitTrans}{wxdbcommittrans} is called on the database connection.\wxheading{Remarks}Transactions begin implicitly as soon as you make a change to the database.  Thetransaction continues until either a commit or rollback is executed.  CallingwxDb::RollbackTrans() will result in ALL changes done using this databaseconnection that have not already been committed to be "undone" back to the lastcommit/rollback that was successfully executed.\normalbox{Calling this member function rolls back ALL open (uncommitted)transactions on this ODBC connection, including all wxDbTable instances thatuse this connection.}\wxheading{See also}\helpref{wxDb::CommitTrans}{wxdbcommittrans} for a special note on cursors\membersection{wxDb::SetDebugErrorMessages}\label{wxdbsetdebugerrormessages}\func{void}{SetDebugErrorMessages}{\param{bool }{state}}\docparam{state}{Either true (debug messages are logged) or false (debugmessages are not logged).}\wxheading{Remarks}Turns on/off debug error messages from the ODBC class library.  Whenthis function is passed true, errors are reported to the user/logged automaticallyin a text or pop-up dialog when an ODBC error occurs.  When passed false,errors are silently handled.When compiled in release mode (FINAL=1), this setting has no affect.\wxheading{See also}\helpref{wxDb constructor}{wxdbctor}\membersection{wxDb::SetSqlLogging}\label{wxdbsetsqllogging}\func{bool}{SetSqlLogging}{\param{wxDbSqlLogState}{ state}, \param{const wxString \&}{filename = SQL\_LOG\_FILENAME}, \param{bool }{ append = false}}\wxheading{Parameters}\docparam{state}{Either sqlLogOFF or sqlLogON (see \helpref{enum wxDbSqlLogState}{wxdbcolfor}). Turns logging of SQL commands sent to the datasource OFF or ON.}\docparam{filename}{{\it OPTIONAL}.  Name of the file to which the log text is to be written.  Default is SQL\_LOG\_FILENAME.}\docparam{append}{{\it OPTIONAL}. Whether the file is appended to or overwritten.  Default is false.}\wxheading{Remarks}When called with {\it sqlLogON}, all commands sent to the datasource engine are logged to the file specified by {\it filename}.  Logging is done by embedded \helpref{wxDb::WriteSqlLog}{wxdbwritesqllog} calls in the database member functions, or may be manually logged by adding calls to \helpref{wxDb::WriteSqlLog}{wxdbwritesqllog} in your own source code.When called with {\it sqlLogOFF}, the logging file is closed, and any calls to \helpref{wxDb::WriteSqlLog}{wxdbwritesqllog} are ignored.\membersection{wxDb::SQLColumnName}\label{wxdbsqlcolumnname}\func{const wxString}{SQLColumnName}{\param{const wxChar *}{ colName}}Returns the column name in a form ready for use in SQL statements.In most cases, the column name is returned verbatim.  But some databases(e.g. MS Access, SQL Server, MSDE) allow for spaces in column names, whichmust be specially quoted.  For example, if the datasource allows spacesin the column name, the returned string will have the correct enclosingmarks around the name to allow it to be properly included in a SQL statementfor the DBMS that is currently connected to with this connection.\wxheading{Parameters}\docparam{colName}{Native name of the column in the table that is to beevaluated to determine if any special quoting marks needed to be added to itbefore including the column name in a SQL statement}\wxheading{See also}\helpref{wxDb::SQLTableName}{wxdbsqltablename}\membersection{wxDb::SQLTableName}\label{wxdbsqltablename}\func{const wxString}{SQLTableName}{\param{const wxChar *}{ tableName}}Returns the table name in a form ready for use in SQL statements.In most cases, the table name is returned verbatim.  But some databases(e.g. MS Access, SQL Server, MSDE) allow for spaces in table names, whichmust be specially quoted.  For example, if the datasource allows spacesin the table name, the returned string will have the correct enclosingmarks around the name to allow it to be properly included in a SQL statementfor the data source that is currently connected to with this connection.\wxheading{Parameters}\docparam{tableName}{Native name of the table that is to be evaluated todetermine if any special quoting marks needed to be added to itbefore including the table name in a SQL statement}\wxheading{See also}\helpref{wxDb::SQLColumnName}{wxdbsqlcolumnname}\membersection{wxDb::TableExists}\label{wxdbtableexists}\func{bool}{TableExists}{\param{const wxString \&}{tableName}, \param{const wxChar *}{userID=NULL}, \param{const wxString \&}{path=""}}Checks the ODBC datasource for the existence of a table.  If a {\it userID}is specified, then the table must be accessible by that user (user must haveat least minimal privileges to the table).\wxheading{Parameters}\docparam{tableName}{Name of the table to check for the existence of.}\docparam{userID}{Owner of the table (also referred to as schema).  Specify a userID when the datasource you are connectedto allows multiple unique tables with the same name to be owned by different users.  {\it userID}is evaluated as follows:}\begin{verbatim}         userID == NULL  ... UserID is ignored (DEFAULT)         userID == ""    ... UserID set equal to 'this->uid'         userID != ""    ... UserID set equal to 'userID'\end{verbatim}\wxheading{Remarks}{\it tableName} may refer to a table, view, alias or synonym.This function does not indicate whether or not the user has privileges to query or perform other functions on the table.  Use the \helpref{wxDb::TablePrivileges}{wxdbtableprivileges} to determine if the user has sufficient privileges or not.\wxheading{See also}\helpref{wxDb::TablePrivileges}{wxdbtableprivileges}\membersection{wxDb::TablePrivileges}\label{wxdbtableprivileges}\func{bool}{TablePrivileges}{\param{const wxString \&}{tableName}, \param{const wxString \&}{priv},\param{const wxChar *}{userID=NULL}, \param{const wxChar *}{schema=NULL},\param{const wxString \&}{path=""}}Checks the ODBC datasource for the existence of a table.  If a {\it userID}is specified, then the table must be accessible by that user (user must haveat least minimal privileges to the table).\wxheading{Parameters}\docparam{tableName}{Name of the table on which to check privileges.{\it tableName} may refer to a table, view, alias or synonym.}\docparam{priv}{The table privilege being evaluated. May be one of thefollowing (or a datasource specific privilege):}\begin{verbatim}    SELECT      : The connected user is permitted to retrieve data for                  one or more columns of the table.    INSERT      : The connected user is permitted to insert new rows                  containing data for one or more columns into the                  table.    UPDATE      : The connected user is permitted to update the data in                  one or more columns of the table.    DELETE      : The connected user is permitted to delete rows of                  data from the table.    REFERENCES  : Is the connected user permitted to refer to one or                  more columns of the table within a constraint (for                  example, a unique, referential, or table check                  constraint).\end{verbatim}\docparam{userID}{{\it OPTIONAL.}  User for which to determine if the privilegespecified to be checked is granted or not.  Default is "".{\it userID} is evaluated as follows:}\begin{verbatim}         userID == NULL  ... NOT ALLOWED!         userID == ""    ... UserID set equal to 'this->uid'         userID != ""    ... UserID set equal to 'userID'\end{verbatim}\docparam{schema}{{\it OPTIONAL.}  Owner of the table.  Specify a userID when the datasourceyou are connected to allows multiple unique tables with the same name to beowned by different users.  Specifying the table owner makes determination of theusers privileges MUCH faster.  Default is NULL.  {\it userID} isevaluated as follows:}\begin{verbatim}         schema == NULL  ... Any owner (DEFAULT)         schema == ""    ... Owned by 'this->uid'         schema != ""    ... Owned by userID specified in 'schema'\end{verbatim}\docparam{path}{{\it OPTIONAL.}  Path to the table.  Default is "".Currently unused.}\wxheading{Remarks}The scope of privilege allowed to the connected user by a given tableprivilege is datasource dependent.For example, the privilege UPDATE might allow the connected user to updateall columns in a table on one datasource, but only those columns forwhich the grantor (the user that granted the connected user) has the UPDATEprivilege on another datasource.Looking up a user's privileges to a table can be time consuming depending on thedatasource and ODBC driver.  This time can be minimized by passing a {\it schema}as a parameter.  With some datasources/drivers, the difference can be severalseconds of time difference.\membersection{wxDb::TranslateSqlState}\label{wxdbtranslatesqlstate}\func{int }{TranslateSqlState}{\param{const wxString \&}{SQLState}}Converts an ODBC sqlstate to an internal error code.\wxheading{Parameters}\docparam{SQLState}{State to be converted

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -