I met a problem, I install a small program written in Delphi, originally can use PB program will not be able to connect the database,
Consult everybody masters, the principle of PB connection used data is what? Which involves the dynamic library file or system configuration information? Please feel free to comment, thank you!
CodePudding user response:
PB with a variety of database connection!!!!!1. The Power how to understand the transaction object in the script language
The original concept
Pass information between application and database structure of a variable, a total of 15 members. You can have a detailed list of all of its members see the PB application will initialize a global structure variables, the SQLCA, of course you can also customize a transaction object.
1 the DBMS string used by the name of the database management system, such as Sybase, Oracle, ODBC,
2 the Database string to connect to the Database name,
3 UserID string used to connect to the database user name, or do not need the DBMS,
4 DBPass string users connect to the database password,
5 the Lock string this is the level of protection in the database, generally don't have to give,
6 LogID string username login to the database server, some do not need the DBMS, but Sybase and Oracle need to specify the parameters,
7 LogPass string user password on the login to the database server, this property can be set up facility, but the Sybase and Oracle need to specify a password,
8 ServerName string database server name,
9 the AutoCommit Boolean
Specifies whether the database is set to automatically submit all transactions, the default is False, that is to say, must carry on the transaction management in application, and at the appropriate time to commit the transaction database, if True, each transaction is submitted by the system automatically,
10 DBParm string is used to transfer special information to the database properties,
11 SQLCode long indicating the latest SQL operation failure or success, its value is: 0 error-free, 100-1 appear a mistake,
There is no data retrieved,
Last time 12 SQLNRows long SQL operations affect the number of rows, different database its meaning is different also,
13 SQLDBCode long database error code, different databases have different meanings,
14 SQLErrText string literal interpretation of the error code corresponding to SQLDBCode attributes,
15 SQLReturnData return to DBMS execute SQL string of additional information, different DBMS its value is different,
2. I often to do use PB program. The ini file to control with the database connection, may only need to modify one convenient for application of transplantation and the database connection parameters can, I want to ask these. Ini file can only use hand writing, I saw many. Ini file parameter doesn't much like handwriting is generated by the machine, don't know how to generate? Please instruct
1, in fact in the PB in the new TOOL -- -- -- - the FILE (EDIT) the INI FILE, EDIT can generate the most direct is the EDIT icon in the toolbar,
2, the machine generated code is: the DATABASE icon - choose connection mode, such as: choose right MSS MICROSOFT SQL SERVER - NEW
PROFILE after fill some parameters according to the requirement in - you can see in the PREVIEW code, copy it to the INI file,
3. Programming experience - PB database connection
Usually in the use of PB and database management system (DBMS) connection, the use of two ways:
A, open interface data sources (ODBC) connection
ODBC is by supporting the Microsoft Open service structure (WOSA, Windows Open Services
Part of the Architecture). Through configuration in the PB
The SQLCA. DBMS='ODBC attributes of the object can make the application through the ODBC connection to the database,
ODBC specific configuration contains a data source, the driver type, the buffer pool all sorts of detail parameters, such as
Example:
The SQLCA. DBMS="ODBC"
The SQLCA. The AutoCommit=False
The SQLCA. DBParm="ConnectString='DSN=xxx_dsn; UID=XXX; The PWD="', ConnectOption='SQL_DRIVER_CONNECT, SQL_DRIVER_NOPROMPT'
"
Second, dedicated database interface
Each database management system (DBMS) is to provide the corresponding client driven, in order to better serve the database,
Here we are using the Microsoft used 2000 client program, by setting the SQLCA. DBMS="MSS
Microsoft SQL Server "to the client through a dedicated database interface to connect to the database,
The parameters of the class interface configuration in addition to the server name, database name, LogId, LogPass outside also includes connection protocol such as user authentication methods, etc., can be configured by the server or client configuration program,
The SQLCA. DBMS="MSS Microsoft SQL Server"//interface type
The SQLCA. Database="master"//database
The SQLCA. Userid=""
The SQLCA. Dbpass=""
The SQLCA. Logid="sa"
The SQLCA. Logpass="XXXX"
The SQLCA. ServerName=". \ "XXX//the server name
The SQLCA. Dbparm="CommitOnDisconnect='No'"
The SQLCA. The autocommit=false
PB are introduced more than a method often used with the database connection,
Tend to choose connection mode according to the different application environment,
More in a single environment using ODBC connection, because on release link relatively easier, more under the network environment using special database connection, which can improve the reliability of the SYSTEM and the execution efficiency, the issue of special database link tend to deserve to go up the corresponding DBMS client dynamic link library (DLL), and put it in the application of the current path, or stored in % % SYSTEM below,
I in the development with the BLOB of data access, we all know that original concept
Support for BLOB field is limited, so every time can only handle 32 KB data block, if a file is more than 32 k must write the corresponding procedures for processing, then the development environment is PWOERBUILDER
9.0 + MS SQL SERVER 2000, Windows,
When reading BLOB fields from the ODBC connection data, through a MESSAGEBOX pop up the number of bytes, observe the file, as long as more than 32 k LEN (BLOB) will make a mistake, always return is 32 k bytes in length, was very confusing, then doubt system problems, check the virus, to install the corresponding development environment, the result is still, the doubt of the ODBC there may be a problem, because Microsoft is expert, is also the expert to solve the problem, when by essentially
Special interface connection, everything is normal, which proves that the ODBC and dedicated database interface between the certain problem,
Which can illustrate various subtle differences among the similar technology, may bring us unexpected problems, still need to be careful when development, fully considering the reliability of the technology used,
CodePudding user response:
The