Connect to a database in a "PB" program

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.