Posts

Showing posts from 2012

PowerBuilder and SQL Server: Tips On Working Together

I recently worked on a project that used PowerBuilder for the front end and SQL Server for the database. I've worked with both of these technologies in the past but this was the first time I used them together. Below are some notes about the things that I learned regarding PB and SQL Server working together. Single Quoted Strings If you do any work with SQL statements in SQL Server Management Studio (SSMS), you'll find that SQL Server only accepts strings if they are surrounded by single quotes. You can use double quotes in the PowerBuilder painters and they'll get translated properly on their way to SQL Server. But you may want to just go ahead and use single quotes everywhere, especially if you are trying to track down a problem by copying SQL from PowerBuilder and pasting it into SSMS. Identity Columns One of my tables had its primary key set in SQL Server to autoincrement. In my datawindow I would insert a row and then do an update. I was expecting the value SQL Server

A PowerBuilder Color Function

While I was working on my PowerBuilder Color Chart , I started thinking about how we use color values in PB datawindow expressions. If you wanted to give every other row in a datawindow a gray background, you might put something like this in the detail band's background expression: if (mod(getrow(), 2) = 0, 16777215, 8421504)) But you'd have to know that 16777215 represents white and 8421504 is the number for gray. A lot of developers take the next step and use the RGB function: if (mod(getrow(), 2) = 0, RGB(255, 255, 255), RGB(128, 128, 128)) Here you specify the Red, Green and Blue values for the color you want and the RGB function returns the proper number. It's still not very easy to tell at a glance what the color is, but it's certainly easier than the first expression. I wanted an easier way to specify a color. So I created a new function, f_color. You pass it one of the PowerBuilder color names and it will return the proper number. For example, our alternate row

My PowerBuilder Color Chart

Image
The other day I went looking for a PowerBuilder color chart. And while I found a few , they weren't exactly what I was looking for, so I created my own. It's available as a PDF here .