Share the small knowledge points, connect the required database in PB, the code is as follows:
Profile Pbtest
SQLCA. DBMS = "ODBC"
SQLCA. autocommit = False
SQLCA. Dbparm = "connectstring= ' dsn=pbtest; Uid=sa; pwd=123456 ' "
The above DBMS is the data driver, Autocommit is connected automatically, Dbparm is the connection configuration of the database: for example, connect the database name and login user (if present)
If, if not written, or forget how to write, we can go to find this piece of code. The connection profile file in the database can be:
Again, you need to go to the database management interface: File--new--database--database painter
Then select the database that we need to connect to, query its configuration information, that is, right-click Properties.
Locate the preview window to view the connection configuration information for the database.
We can test it first and copy the code in the box if it succeeds
Write this code where the database was first used in the program.
In general, in order to avoid possible exceptions, we need more rigorous validation, which is required when connecting to a database in a program. In general, we will attach a name to the program to represent the connection. It then verifies that the database is unblocked between the programs by verifying the existence of the name. Such as:
Connect using Sqlca;
If Sqlca.sqlcode<>0
then MessageBox ("Error", "System cannot connect to database, please check!", stopsign!) Connection exception prompt for
else
//program executed after successful connection
End If
Well, this small knowledge points to share here, if necessary, please private messages or in the blog comment area to leave your valuable suggestions, welcome to communicate more.