This article explains in the most simpliest terms how to use action script to connect to SQL Server via an ashx (ASP.Net) file in order to extract data for display in your flash application.

First, you build a flash game that keeps track and stores the gamer’s score. Before we even discuss that (in another article: http://www.jamesandchey.net/?p=543),
we want to retrieve the top score from the database saved from a previous game and display it to the current gamer.

To retreive the top score, you need to add code to your action script to call an ashx file on your server.

First, define a URLLoader variable.

Next, define a URLRequest variable that contains the url location of your ashx file. Also, assign the GET method to your URLRequest variable.

You then need to define an event listener to your URLLoader so it can fire a function (that you define) once the data is returned to your flash application via the ashx file.
The function you define will take the data (built in XML format by the ashx file) and load it into textbox variables for display.

Lastly, execute the load method of the URLLoader passing as a parameter the URLRequest variable.

This article explains in the most simpliest terms how to use action script to connect to MySQL via a php file in order to extract data for display in your flash application.

First, you build a flash game that keeps track and stores the gamer’s score. Before we even discuss that (in another article: http://www.jamesandchey.net/?p=530),
we want to retrieve the top score from the database saved from a previous game and display it to the current gamer.

To retreive the top score, you need to add code to your action script to call a php file on your server.

First, define a URLLoader variable.

Next, define a URLRequest variable that contains the url location of your php file. Also, assign the GET method to your URLRequest variable.

You then need to define an event listener to your URLLoader so it can fire a function (that your define) once the data is returned to your flash application via the php file.
The function you define will take the data (built in XML format by the php file) and load it into textbox variables for display.

Lastly, execute the load method of the URLLoader passing as a parameter the URLRequest variable.

Let’s say you have a table called ‘car_make’ and another table called ‘car_model’. There is a one to many relationship between make and model. You want to bring back a result set of all makes, 1 row per make, but you want only 1 generated column for model that has all the models concatenate into that 1 column. Let’s say you have 4 models for your 1 make of Chevy. Here is the output of what you are striving for:

Let’s say you create a web site, and you want to add recaptcha to the aspx page where clients can sign up for an account. Instead of a custom sign up form, you instead use Microsoft’s CreateUserWizard control. I’ll explain how you can use both the CreateUserWizard and recpatcha controls effectively.

First, go to the recpatcha web site, follow the online instructions to create an account and retrieve your public and private keys, then download the recpatcha dll library and place them in your bin folder of your web site project. Next, add a reference to the Recaptcha.dllhttp://www.google.com/recaptcha

On the same aspx page that hosts the CreateUserWizard, enter the following in the source for the recaptcha control.

Since you will not be using a submit button for your recaptcha control, you will instead validate the text entered in the recpatcha control on the server side within your CreateUserWizard_CreatingUser event as follows:

If Page.IsPostBack Then
recaptcha.Validate()
If recaptcha.IsValid = False Then
e.Cancel = True
lblResult.Text = "Text does not match RECAPTCHA. Please try again."
End If
Else
lblResult.Text = String.Empty
lblResult.Visible = True
End If

Note: recaptcha.Validate() is a method within the recaptcha.dll that will compare the text entered and the text image. If the recaptcha.isValid = False, setting e.Cancel = True stops the CreateUserWizard from proceeding with creating the user. You also would send the error message to a label you defined on your aspx form stating the RECAPTCHA did not match.

If the recaptcha.Validate isValid = True, you can make the recaptcha control invisible on your form along with a message stating the user was created successfully by adding the following code to your CreateUserWizard_CreatedUser event as follows:

After developing a web site that uses Forms Authentication, you need to create a SQL database that stores the client’s log-in information along with any profiles. The tool that creates the tables in your database that is needed for your application exists on your computer within the .NET Framework.

1) Log in to your cPanel and create a SQL Database and call it what you want. For example: MyDatabaseASPNETDB

2) Assign and user and password to the Database.

3) Run the ASP.Net SQL Server Setup Wizard located in your .NET Framework directory. The wizard is called aspnet_regsql.exe.

For example, the path might be C:WindowsMicrosoft.NETFrameworkv2.0.50727aspnet_regsql.exe

You decided to build a “Web Site” and not a “Web Solution”. You proceed to use the PUBLISH utility in Visual Studio and publish your entire site to your host. You later make a change to your Web Site and discover that using the PUBLISH utility will only publish the entire site all over again. I don’t have to tell YOU why sometimes that causes headaches. What publish does is actually wipe out CLEAN your entire virtual folder.

How to get around this?

Pre-compile your Web Site and FTP only the updates.

How is this done?

Initially publish your Web Site from Visual Studio with the option checked – “Allow this precompiled site to be updatable. This will publish then entire site but also allow you to later “update” the site using the pre-compile feature.

1) Create a new folder on your hard drive that will contain the destination of your pre-compiles.

Note: Depending on your version of visual studio affects the framework sub folder name. Replace [your web site folder] with the path on your computer where your web site files exist. Replace [your web site precompile folder] with the path on your computer where your pre-compile will be generated after running the pre-compile.

3) Sign on to your favorite FTP and overlay just the dll’s in the bin folder and all your aspx pages.

Note: Why aspx pages? Because the pre-compile replaces in the Page declaration of each aspx page, CodeFile=”xxxx.aspx.vb” with inherits=”xxxx_POST, App_Web_????????” In other words, it replaces the name of the vb code behind file with the actual dll it executes.