FireworksColdFusionDreamweaverFreehandFlashMXHome
Latest New Content

Latest Free Content
View All
Free Content
Accessibility
CMX Learning Guides
Hosted by enterhost

Porting Pollster to SQL Server

By: Paul Newman

Page 1 of 3

Set for printing

Next

One of the most popular widgets in Macromedia's DevNet Resource Kit Volume 4 (DRK 4) is Pollster. This "rich Internet application" implements ColdFusion templates, ColdFusion components (CFCs), Flash MX, and Flash Remoting MX to enable users to create and manage their own online polls. You can see Pollster in action on Christian Cantrell's weblog.

The Pollster demo included in DRK 4 uses a Microsoft Access database. For production servers, Macromedia recommends using PostgreSQL or upsizing the Access database to SQL Server. To spare you the hassle, I created a SQL script that generates the necessary Pollster tables on SQL Server. You'll find pollster_build.sql in this tutorial's support files at the bottom of this page.

NOTE: According to Macromedia, they did not include a build script for MySQL "because Pollster uses subselects, which are not yet supported in full releases of MySQL."

To get Pollster up-and-running on SQL Server/IIS, we have to make three key changes to the application:

  1. Install the SQL Server database tables
  2. Revise the ColdFusion Components
  3. Change the authentication method

Before we proceed, you should copy the Pollster application from DRK 4 into your ColdFusion web root (e.g., C:\CFusionMX\wwwroot\pollster). This way, you can revise the application without making changes to the original Microsoft Access version.

Installing the SQL Server Database Tables

To install the Pollster tables on SQL Server, run the SQL script, pollster_build.sql, in Query Analyzer:

  1. Launch SQL Server Query Analyzer (Start > Programs > Microsoft SQL Server > Query Analyzer).
  2. Select your SQL Server from the drop-down menu and log in to Query Analyzer.
    Figure 1
  3. In Query Analyzer, click Load SQL Script on the toolbar (Ctrl+Shift+P).
  4. Browse to pollster_build.sql on your computer and click Open. This loads the SQL script into the Editor pane.
  5. If you're adding the Pollster tables to an existing database, replace pollster (line 15) with the name of your database.
    Figure 2
    Otherwise, uncomment lines 9-11 to create a new SQL Server database named pollster.

TIP: To uncomment lines 9-11, simply delete lines 8 and 12. Multiple-line /* SQL comments */ use forward slash-asterisk character pairs, just like JavaScript.

  1. At this point, you should verify that your SQL Server database doesn't already contain tables named Polls, Options, or Responses.
  2. Click Execute Query (or press F5) to run the SQL script. "The command(s) completed successfully" should appear in the Messages pane. (If you're creating a new database, the message will indicate that the CREATE DATABASE process is allocating space on the disk for the pollster database.)
  3. To verify that the tables were created, expand the User Tables folder for your database in Object Browser (Tools > Object Browser > Show/Hide).

At this point, you should have three new tables in your SQL Server database: Polls, Options, and Responses. The SQL script generates the same structure, or schema, as the Microsoft Access database. In addition, it creates the same primary key-foreign key constraints implemented in the SQL script that accompanies the Pollster application (postgresql_build.sql).

Later on, you can repeat the steps above to create the tables on your production server. Many online control panels enable you to create new SQL Server databases yourself. If not, contact your hosting provider and ask them to create the database for you. Needless to say, make sure to note the server name, database name, login name and password of the remote SQL Server database for future reference.

TIP: To connect to remote instances of SQL Server, you need to create a new Server Alias using the Client Network Utility (Start > Programs > Microsoft SQL Server > Client Network Utility). Once you've created the Alias, you must register it using the Register SQL Server Wizard in Enterprise Manager (click Register Server on the Enterprise Manager toolbar). For more information, see Books Online (Start > Programs > Microsoft SQL Server > Books Online).

In the next step, we'll revise two of Pollster's ColdFusion components to accommodate SQL Server.

Page 1 of 3 1 2 3 Next


download
Download Support Files


Keywords
pollster, drk, devnet resource kit, sql server, coldfusion, flash remoting, cfc