Thursday, January 13, 2011

Switch Database on Login Page with PowerBuilder


Many ways to connect in mysql database in PowerBuilder.To perform database selection directly on the login page using PowerBuilder application and database mysql we can use this script that can be placed on the login button.
Put your drop down list box on login page as a swicth control to database (ls_db). For exp we can say production_db for real operation and UAT_db for testing application. this is
pretty easy ok

//=== variable ==
String ls_db Integer li_install, li_count


ls_db = ddlb_0.text

////***** Profile database******for mysql****
SQLCA.DBMS = ProfileString(gs_path + "\proto.INI",ls_db,"DBMS", " ")
SQLCA.AutoCommit = false
SQLCA.DBParm= ProfileString(gs_path + "\proto.INI",ls_db,"DbParm", " ") + ";UID=root;PWD=mounxxxx;OPTION=135168',DisableBind=1,StaticBind=0,PBUseProcOwner=NO"

connect using sqlca;

if isnull(sqlca.sqlcode) or sqlca.sqlcode <> 0 then
messagebox("Database Not Connect ",string(sqlca.sqlcode)+sqlca.sqlerrtext)
return
else

//…open the application

End if

No comments: