Set ODBC Custom CSETODBC (1)

xiaoxiao2021-03-06  138

First, the function description is used to configure the data source username and password. You can get a connection string, which can be used for getDefaultConnect () of CMYRECORDSET (), or use dry CDatabase class OpenEx.2, if the user configures correct It only needs to be configured once, the relevant information is recorded in the file .3, you can specify the file name of the stored information. Because there may be several probes to share a data source. 4. The user can reconfigure the data 5, which can get the current data. 6 It can be used to modify the current database. It is difficult to use a unified style. 7, the user can select the data source. 8, there must be enough information to let the user know why configuring data Source, one program may need to configure multiple data sources. 9, must have a message when configuring an error. 10, the password must be encrypted .11, may record multiple data sources in the same file. Second, system design 1, join string The parameter form of CDATABASE :: OpenEx is "DSN = SQLSERVER_SOURCE; UID = SA; PWD = ABC123". The form of "ODBC; DSN = TestodBC" is: strconnect.format (" DSN =% S; UID =% S; PWD =% s ", m_strdsn, m_struid, m_strpwd); getDefaultConnect () When using" ODBC; "2, record information, file name users in reading and writing You can specify the file name. If you do not specify a file name, use the default file name. If you do not specify the default file name, read and write the registry .3, reconfigure the data csetoDBC :: getConnectStr (Bool Bresh), parameter bset is true .4 You can get the database full connection string of the current data, so you can record the database type in m_strtype in csetoDBC :: getConnectSTR (Bool Breset). CsetoDBC :: getDbType () Judging whether it is successfully connected, if There is no reconnection. 5, some data can only support some style, so based on the experience of the CSETODBC :: GetWriteDBStyle () function. 6, select (new) data source CDatabase, OpenEX will pop up the dialog box, you can create You can also choose the data source. 7, the password must encrypt the use of specialized encryption decryption functions. Encryption decryption is placed in the same function, which can reduce inconsistency .8, a file records multiple data sources use different section names (m_strappname). The section also affects the title of the dialog. III, class structure (1), member variables cstringm_strdsn; dsncstringm_strpwd; password cstringm_struid; user name cstring m_strappname; section name, there may be several different data source cstring m_strfilename; record related information File, if it is empty in the registry .cstring m_strdbtype; database type (2), member function cstract getConnectStr (Bool Breset = false); getting a connection back onbuttonodbc (); button response function, pop-up dialog to make users choose or create a new data source DWORD CSetODBC :: GetWriteDBStyle (CString strDBType = ""); get to write database style Set, get function void SetFileName (CString strFileName); void SetAppName (CString strAppName); CString GetDBType (); bool ReadFromFile (CString strFileName = ""); Read data Bool WriteTofile (CString strfilename = ") from the file; write data into the file cstring getdbtypefrommergeConnectStr (CString strconnect);

转载请注明原文地址:https://www.9cbs.com/read-127420.html

New Post(0)