Power Builder connects to multiple databases at the same time

Source: Internet
Author: User

You only need to set two transaction pairs.
The following example shows how to connect the SQL Server and DBF databases at the same time:
Connect to SQL Server:
Setpointer (hourglass !)
// The window is in the middle
F_center (this)
// A set of different sgselect connections
String sselect
String temp
Sselect = "d_gdzc" + sgselect
Sqlca. dbparm = profilestring (gzinifile, "Database", "dbparm ","")
Sqlca. DBMS = profilestring (gzinifile, "Database", "DBMS ","")
Sqlca. Database = sselect
Sqlca. servername = profilestring (gzinifile, "Database", "servername ","")
Sqlca. logid = "sa"
Registryget ("HKEY_CURRENT_USER/software/Microsoft/Windows/CurrentVersion/Explorer/g", "A", regstring !, Temp)
F_anencrypt (temp, sqlca. logpass)
Sqlca. autocommit = false
Sqlca. Lock = profilestring (gzinifile, "Database", "Lock ","")
Connect using sqlca;

If sqlca. sqlcode <> 0 then
MessageBox ("lost connection ",&
"Cannot be connected to the data base! (Error message: "+ sqlca. sqlerrtext + ")")
Setpointer (arrow !)
Return
Halt close
End if

Fixed number of letters:
Fuction f_connectdbf (string sdbparm) return any
String NUL // used to generate a null value
Transaction trans_name
Trans_name = create transaction
Trans_name.dbms = "ODBC"
// Trans_name.database = "zwdbf"
// Trans_name.logid =
// Trans_name.logpass =
Trans_name.autocommit = false
Trans_name.dbparm = sdbparm
// Trans_name.lock = profilestring (gzinifile, "Database", "Lock ","")
// Trans_name.dbparm = profilestring (gzinifile, "Database", "dbparm ","")
Connect using trans_name;

If trans_name.sqlcode <> 0 then
MessageBox ("lost connection ",&
"Cannot be connected to financial data warehouse! Check whether the path is correct. (Error message: "+ sqlca. sqlerrtext + ")")
Rollback;
Return setnull (NUL)
Else
Return trans_name
End if

Connect to the Foxpro Data Base (connect to the second data base at the same time, and connect to the third and fourth databases ):
Openwithparm (w_disp, "connecting the DBF card data library...", parent)
Transaction sqldbf
// Use sqldbf to connect to the finance (solid-capital) Data Base
Sqldbf = f_connectdbf ("connectstring = 'dsn = gzdbf '")
// Determine whether the disconnection is successful.
If isnull (sqldbf) then
MessageBox ("error", "error occurred when connecting to DBF fixed asset data database! ")
End if

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.