Skip to Content
Author's profile photo Bruce Armstrong

Interfacing with the Google Data API from PowerBuilder.Net

Recently somebody asked me for help getting PowerBuilder.Net (and eventually PowerBuilder Classic through a COM Callable Wrapper) to interface with Google Calendar.  That actually turned out to be fairly simple because Google provides a .Net library for Google Data API which provides access not only to Google Calendar, but to a number of other Google services as well, such as Blogger, Contacts, Picasa Web Albums, Spreadsheets and YouTube.

We’re going to see just how easy by accessing Google Calendar and retrieving our events for the next few days.  To do that, first download and install the Google Data API .net libraries (you only need the first one on the list).  Then create a PowerBuilder.Net WPF project and add references to the Google.GData.AccessControl, Google.GData.Calendar, Google.GData.Client and Google.GData.Extensions assemblies.


You’ll want to create a DataWindow to hold the results of the query. For this sample, I just created an external source datawindow with two columns, one to hold the event date/time (eventdate) and another to hold the title of the event (eventtitle).

Once you’ve done that, add a command button to the window and add code similar to the following to it’s clicked script.  You’ll need to add your own Google email and password information:

Google.GData.Calendar.CalendarService service
Google.GData.Calendar.EventQuery query
Google.GData.Calendar.EventFeed calFeed
System.Collections.IEnumerator entries
Google.GData.Calendar.EventEntry entry
System.Collections.IEnumerator dates
Google.GData.Extensions.When date
string        title
datetime start
long     row
service = create Google.GData.Calendar.CalendarService("PBCalendarSampleApp")
service.setUserCredentials(<gmail address>, <password>)
query = create Google.GData.Calendar.EventQuery()
query.Uri = create System.Uri("")
query.StartTime = System.DateTime.Now.AddDays(-28)
query.EndTime = System.DateTime.Now.AddMonths(6);
calFeed = service.Query(query)
entries = calFeed.Entries.GetEnumerator()
do while entries.MoveNext()
     entry = entries.Current
     title = entry.Title.Text
     dates = entry.Times.GetEnumerator()
     do while dates.MoveNext()
         date = dates.Current
         start = date.StartTime
         row = dw_1.InsertRow(0)
         dw_1.Object.eventtitle[row] = title
         dw_1.Object.eventdate[row] = start

So, here’s my sample calendar for the demo:


And here’s the WPF app PowerBuilder.Net created accessing the data.


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.