Add an ASP.NET Web Service to your next Flash Project to assist in Database Connectivity
Feb
28
Written by:
2/28/2011 12:06 PM
We've read a lot of articles recently about client side technologies, their shortcomings, their predicted lifetime and when it's suggested to do certain tasks on the server instead of through a client side solution. I recently wrote an ASP.NET web service for completerentalls.ca to enable their Flash CS5 application to obtain query results from their database. Here are a few things I learned through the process:
First, since we were using an Access database, it was important to place the .mdb file in the App_Code folder of the ASP.NET web service solution. In doing so, this took away the guess work of where the database file would be located once deployed to the server.
Second, I strongly encourage utilizing a query if you're going to be working with an Access database. It's never a good idea to directly hit your database table with queries, and this situation was no exception.
Finally, the web service itself need not be complicated. Since we were executing one query against the database, only one web service method was defined. Rely on your old friends, dataset, datatable and OLEDBAdapter to setup the web service. Once it's created, the web service can be called from Actionscript's WebService method. Ensure that your naming conventions are consistent in your Actionscript file and your web service.
This is just one of many situations where one can leverage the strengths of client-side technologies like Flash as well as those of server-side technologies like ASP.NET web services. In doing so, you'll utilize the tools you desire and produce an effective and responsive solution.
Happy Coding!!