One of the easiest way to connect to MySQL DB from Powerbuilder is thru ODBC connection. You have to install latest version of MySQL ODBC Driver from their official site: https://dev.mysql.com/downloads/file/?id=415028 Download the 32 bits version
Showing posts with label Tricks. Show all posts
Showing posts with label Tricks. Show all posts
Tuesday, March 7, 2017
Monday, September 26, 2016
SQL Server Function to Get How Long in Word
This below SQL User Defined Function script is to returns How Long the date already passed, in wording. It's usually displayed in articles to inform the reader how long the article already posted.
Friday, September 23, 2016
Return SQL Server 2016 JSON format In 1 row format
The newest version of Microsoft SQL Server, which it version 2016, comes with JSON native support. So you don't need to convert anymore at script side with 3rd party module like Newtonsoft library.
Thursday, September 8, 2016
SQL syntax to show all days in a week
This is SQL SERVER trick is to show the entire daily data from database even there is no transaction data in a particular day
Let say you have a table with the below structure
Table: dailysharelike
Columns:
datetimetrans DATETIME
share_number INT
like_number INT
The data rows are
2016-09-05 00:00:00 | 2 | 1
2016-09-05 00:00:00 | 2 | 3
2016-08-25 00:00:00 | 10 | 1
2016-08-30 00:00:00 | 100 | 90
2016-08-25 00:00:00 | 150 | 80
If you do the query with simple query:
then you will get this (without Sunday, Wednesday, Friday and Saturday)
2 | Monday | 4 | 4
3 | Tuesday | 100 | 90
5 | Thursday | 160 | 81
To show all the days in a week, you can use this syntax
1 | Sunday | 0 | 0
2 | Monday | 4 | 4
3 | Tuesday | 100 | 90
4 | Wednesday | 0 | 0
5 | Thursday | 160 | 81
6 | Friday | 0 | 0
7 | Saturday | 0 | 0
Let say you have a table with the below structure
Table: dailysharelike
Columns:
datetimetrans DATETIME
share_number INT
like_number INT
The data rows are
2016-09-05 00:00:00 | 2 | 1
2016-09-05 00:00:00 | 2 | 3
2016-08-25 00:00:00 | 10 | 1
2016-08-30 00:00:00 | 100 | 90
2016-08-25 00:00:00 | 150 | 80
If you do the query with simple query:
SELECT DATEPART(dw,datetimetrans) AS weekdaynum, DATENAME(dw,datetimetrans) AS weekdayname,
ISNULL(SUM(like_number),0) AS like_number,
ISNULL(SUM(share_number),0) AS share_number
FROM dailysharelike
GROUP BY DATEPART(dw,datetimetrans), DATENAME(dw,datetimetrans)
GROUP BY DATEPART(dw,datetimetrans), DATENAME(dw,datetimetrans)
then you will get this (without Sunday, Wednesday, Friday and Saturday)
2 | Monday | 4 | 4
3 | Tuesday | 100 | 90
5 | Thursday | 160 | 81
To show all the days in a week, you can use this syntax
SELECT DISTINCT weekdaynum, weekdayname, SUM(like_number) AS like_number,
SUM(share_number) AS share_number FROM
(SELECT 1 AS weekdaynum, 'Sunday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT 2, 'Monday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT 3, 'Tuesday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT 4, 'Wednesday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT 5, 'Thursday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT 6, 'Friday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT 7, 'Saturday' AS weekdayname, 0 AS like_number, 0 AS share_number UNION
SELECT DATEPART(dw,selfie_upload) AS weekdaynum, DATENAME(dw,selfie_upload) AS weekdayname,
ISNULL(SUM(like_number),0) AS like_number,
ISNULL(SUM(share_number),0) AS share_number
FROM selfie
GROUP BY DATEPART(dw,selfie_upload), DATENAME(dw,selfie_upload)
) AS hasil GROUP BY weekdaynum, weekdayname
ORDER BY weekdaynum, weekdayname
1 | Sunday | 0 | 0
2 | Monday | 4 | 4
3 | Tuesday | 100 | 90
4 | Wednesday | 0 | 0
5 | Thursday | 160 | 81
6 | Friday | 0 | 0
7 | Saturday | 0 | 0
Monday, January 18, 2016
Windows 10 GodMode
Here's the trick to enable Windows 10 GodMode
- Make a new folder in your desktop
- Rename the folder into
GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
- Now the Godmode shortcut and icon will appear
- Do it with your own risks
Tuesday, September 15, 2015
Send SMS with Powerbuilder
Even prestige has begun to decline, in fact, text message (SMS / Short Message System) is still used for 2-way mobile communication. SMS even today is used as a medium for authenticating an application, especially those related to security issues. From social media applications such as Facebook and Twitter, to the e-commerce and even banking applications such as internet banking.
Tuesday, August 11, 2015
Installing Ghostscript on Windows 10
One of the lack of Powerbuilder feature or function is the native exporting the datawindow object into PDF format. Yes, you can use the SaveAs function in the datawindow object, but for PDF format, you need 3rd party application called Ghostscript to be installed on your PC.
Wednesday, May 20, 2015
Powerbuilder Function to Check Email Address Validity
This function was made based on Visual Basic scripting. The original was created by Chad M. Kovac, and I tried to translate into Powerbuilder language and fix some minor bugs.
Saturday, October 18, 2014
Remove Facebook Account in OSX
When you upgrade your OSX version to the newest one, usually will followed by iPhoto application. Then when you open iPhoto application, there's will be Facebook Account in SHARED directory, and automatically will syncing all the photo from your Facebook account.
Saturday, June 28, 2014
Fingerprint Verification with Powerbuilder
Mr. Yakov Werde, one of the Powerbuilder guru, shown us how to use a free SDK for fingerprint device within Powerbuilder. He using Powerbuilder version 12.5 and free fingerprint SDK from Neuro Technology.
This video shows how to do it in detail
This video shows how to do it in detail
Thursday, April 3, 2014
Powerbuilder Function to Get Last Date in Month
This function is to get last date in particular month
Create a function named f_lastdate
Specify a date type as return value
Specify a date type parameter name dTgl, then type this script below
To use the function, use this script
dLastDate value should be: 30 April 2014, if assume today is 3rd April 2014.
Create a function named f_lastdate
Specify a date type as return value
Specify a date type parameter name dTgl, then type this script below
1: integer iMonth, iDate
2: iMonth = Month(dTgl)
3: CHOOSE CASE iMonth
4: CASE 1, 3, 5, 7, 8, 10, 12
5: iDate = 31
6: CASE 4, 6, 9, 11
7: iDate = 30
8: CASE 2
9: IF isDate( '29/' + String(iMonth) + '/' + String(Year(dTgl))) THEN
10: iDate = 29
11: ELSE
12: iDate = 28
13: END IF
14: END CHOOSE
15: dTgl = Date( String(iDate) + '/' + String(iMonth) + '/' + String(Year(dTgl)))
16: RETURN dTgl
To use the function, use this script
1: Date dLastDate
2: dLastDate = f_lastdate(today())
dLastDate value should be: 30 April 2014, if assume today is 3rd April 2014.
Saturday, January 12, 2013
Web CD Player with Powerbuilder & Appeon
Chris Pollach, one of master of Powerbuilder demonstrated the power of Appeon. Build with Powerbuilder 12.1 and compile to be pure web-based version with the Appeon. He made the CD player application.
Read the full article and download the apps for free.
Read the full article and download the apps for free.
Wednesday, November 14, 2012
Webcam with Powerbuilder
Going back to March 2012, someone call Grace posted the script in Powerbuilder about how to using webcam with Powerbuilder, powered by EZTW32.dll
So, I shared the file to all of you, who need also using webcam within Powerbuilder. I didn't her permission to share this, since I assume her already shared in the group. Anyway, thanks to Grace :)
Here's you can download the file: webcam powerbuilder.
So, I shared the file to all of you, who need also using webcam within Powerbuilder. I didn't her permission to share this, since I assume her already shared in the group. Anyway, thanks to Grace :)
Here's you can download the file: webcam powerbuilder.
Tuesday, October 23, 2012
Decimal to Binary function in Powerbuilder
After Binary to Decimal function posted several weeks ago, I try to make Decimal to Binary function with Powerbuilder
Wednesday, September 12, 2012
Binary to Decimal function in Powerbuilder
This script below is the user function in Powerbuilder to convert Binary number into Decimal number.
Create function name: f_bintodec, set Integer as return value, and add sBin as parameter. sBin should be String type, and choose Value as Pass By.
Create function name: f_bintodec, set Integer as return value, and add sBin as parameter. sBin should be String type, and choose Value as Pass By.
Wednesday, September 5, 2012
Calling Web Service from Powerbuilder
On the last post, I explained how to make web service with Powerbuilder. This time I will explain how to access the web service via PowerBuilder. I am using the Classic version of PowerBuilder 12.5.
The scenario is you have a windows application created with PowerBuilder and you want to access a web service over the internet within the Powerbuilder application.
All you need is certainly a web service that is ready to use. You can get it for free on the internet, or create your own web service. In this example I will create a self service web applications using Visual Studio 2008 and run. NET framework 3.5. In the web service, there is a function that we named of_add2value which serves to add 2 numbers through which we put on the parameters of these functions.
The scenario is you have a windows application created with PowerBuilder and you want to access a web service over the internet within the Powerbuilder application.
All you need is certainly a web service that is ready to use. You can get it for free on the internet, or create your own web service. In this example I will create a self service web applications using Visual Studio 2008 and run. NET framework 3.5. In the web service, there is a function that we named of_add2value which serves to add 2 numbers through which we put on the parameters of these functions.
Tuesday, July 3, 2012
Picture Control on Grid Datawindow
Anvil-of-time, one of my colleague, expert on Powerbuilder programming, share to us how to using picture control on Grid Datawindow. One of importing feature on grid datawindow is capability to re-size the column width in user side, like what you have see on Microsoft Excel.
And because of re-size feature, when we put the picture control inside the grid datawindow, when we do the column resizing, the picture will stretched following the size of the column.
Let's take a look of the full article of the tips and trick how to using picture control in grid datawindow, by clicking here
And because of re-size feature, when we put the picture control inside the grid datawindow, when we do the column resizing, the picture will stretched following the size of the column.
| (c) Anvil-of-time |
Let's take a look of the full article of the tips and trick how to using picture control in grid datawindow, by clicking here
Thursday, February 16, 2012
Powerbuilder Datastore
Basicly, DataStore is a nonvisual DataWindow control.
DataStores act just like DataWindow controls except that many of the visual properties associated with DataWindow controls do not apply to DataStores. However, because you can print DataStores, PowerBuilder provides some events and functions for DataStores that pertain to the visual presentation of the data.
Why and when DataStore is used?
We use the datastore, if we want to work with the data in datawindow, but only at the background. User doesn't need to see the data itself. Yes, indeed, we can use datawindow also to do that, with disable in the visible property. But, it's mean you need to insert the database control on your application, and also means that the control will always in the memory as long as the application is running. With the datastore, you just need to create the control when is needed, and can be destroyed when no longer needed.
Creating Datastore
First of all, you need the datawindow object. Create the datawindow object, and named as "d_mydatawindow".
1: // declare the variable
2: DataStore dsMyDataStore
3:
4: // create the control
5: dsMyDataStore = Create DataStore
6:
7: // assign the datawindow object to datastore
8: dsMyDataStore.DataObject = "d_mydatawindow"
9:
10: // bind the data
11: dsMyDataStore.SetTransObject(SQLCA)
12: dsMyDataStore.Retrieve()
13:
14: // script to process the datastore control, same treatment like datawindow control except the visual functions or properties.
15: .....
16:
17: // destroy datastore
18: DESTROY myDataStore
Wednesday, February 15, 2012
How to get screen resolution with Powerbuilder
This is the "old" trick, to get the screen resolution.
I'm using Powerbuilder reserved function, call GetEnvironment, which it can be used for another purpose beside screen resolution.
First of all, we must create a ENVIRONMENT variable like below
1: environment myEnv
Then we use GetEnvironment function to get the data(s).
1: GetEnvironment(myEnv)
Finally, we retrieve all the Environment objects, depending what kind of information do you need. For this case, I want to show how to get the screen resolution:
1: messagebox("Screen Resolution",String(myEnv.ScreenWidth) + "x" + String(myEnv.ScreenHeight))
For the complete Environment Object, you can search the Powerbuilder Help, or see the list below.
| Environment property | Datatype | Description |
|---|---|---|
| CharSet | CharSet (enumerated) | The international character set used by PowerBuilder. Values include:
|
| ClassDefinition | PowerObject | An object of type PowerObject containing information about the class definition of the object or control. |
| CPUType | CPUTypes (enumerated) | The type of CPU. For a complete list of CPUTypes values, see the Enumerated tab of the Browser. |
| Language | LanguageID (enumerated) |
Specifies the value of the language setting for the machine. For a complete list of LanguageID values, see the Enumerated tab of the Browser. |
| MachineCode | Boolean | Specifies whether the application executable is machine code (compiled). Values are:
|
| OSFixesRevision | Integer | The maintenance version of the operating system. |
| OSMajorRevision | Integer | The major version of the operating system. For example, this value would be 4 for Windows 95, 98, ME, and NT 4.x, 5 for Windows 2000, XP, or 2003, and 6 for Vista, Windows Server 2008, and Windows 7. |
| OSMinorRevision | Integer | The point release of the operating system. For example, this value would be 0 for Windows Server 2008 and Vista, 1 for Windows XP or Windows 7, 2 for Windows Server 2003 and 64-bit XP, and 10 for SunOS 5.10 (Solaris 10). |
| PBBuildNumber | Integer | The build number of this version of PowerBuilder. |
| PBFixesRevision | Integer | The maintenance version of PowerBuilder. |
| PBMajorRevision | Integer | The major version of PowerBuilder. |
| PBMinorRevision | Integer | The point release of PowerBuilder. |
| NumberOfColors | LongLong | Number of colors on the screen. |
| ScreenHeight | Long | Height of the screen in pixels. |
| ScreenWidth | Long | Width of the screen in pixels. |
| OSType | OSTypes (enumerated) | Operating system or environment. For a complete list of OSType values, see the Enumerated tab of the Browser. |
| PBType | PBTypes (enumerated) | Version of the PowerBuilder product. For a complete list of PBType values, see the Enumerated tab of the Browser. |
| Win16 (obsolete) | Boolean | Indicates the type of the operating system in which the application executable is running. Values are:
|
Wednesday, February 1, 2012
Working with PBR file
When you create or build an application, sometimes you need to add external resource like image, sound or even non standard font.
In Powerbuilder, you have 2 options when you have external resource files.
- You always have to copy all the external resource files (*.bmp, *.jpg, *.wav etc) into the client computer, as well as concurrent when you copy your application (*.exe , *.dll files).
- You combine all the necessary external files into your application, so you no longer need to copy the files.
The first option has some minus points, example: user can delete by themself the external files. The application may still running, but in some parts, the image will blank.
The second option is not without value minus. The consequence is the application file will be very large. But it would be safer because at least the user can not arbitrarily remove its files.
To implement the second option, Sybase has provided a facility to handle this problem. By using the PBR (Powerbuilder Resource) file, we can put all the file names, along with a complete path, into the application.
Make a PBR file using the Edit menu, and save the file name with extention PBR.
Do not forget to include it in the PBR file in your project, in the Resource file name.
![]() |
| Put your PBR file in your project |
All files listed in the PBR list, will automatically be compiled and incorporated into the application file, so you no longer need to copy it to every computer user.
Subscribe to:
Posts (Atom)

