Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Web Design Pricing Dreamweaver Templates Web Applications Free Tutorials About Contact Us
Services > CSS Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Reliable Web Hosting | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Logo Design Portfolio | Web Design Pricing > Custom Web Design | Logo Design | Business Card Design
Web Design Guide > Website Design w/ Dreamweaver & Fireworks | Fireworks CS4 Cool Features | Photo Effects | Text Effects | Graphic Design Ideas | Web Design Ideas
Website Navigation Ideas | CSS Styles Tutorial | Dreamweaver Template | Server Side Includes | Flash Tutorials > Flash Effects | Flash Sound Button | Sound On/Off Button
Flash Preloader | Import External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

Flash sends data to the Database

Flash form sends data to the database using ASP

Learn how to send data from your Flash interface into your database using ASP programming. This section is most probably the easiest of the whole Flash and ASP integration tutorial series. It is divided into three parts:

  1. Preparing the Flash form interface
  2. Getting the form sending data to the database to work
  3. Carrying out the insert operation through ASP

This involves the following functional cycle which needs to be realized:

  1. Flash sends the data from the 'Input Form' to the ASP file
  2. ASP sends the data to be stored to the database
  3. ASP sends the result of its operation (success or failure) to the Flash interface
  4. Flash sets a counter while the ASP inserts the data and shows success or failure of the operation

Note: Values or code you will have to enter are given in light blue and red Italics show specific settings to be followed by you. All ASP code can be directly cut and pasted into your file. Comments in ASP are in green.

Starting Flash Guest-Book Interface


Preparing the Flash Interface

Flash Guest-Book Send function interfaces

1. Input Form: You will have to assign variable names to the three fields shown by right clicking the respective boxes and selecting the properties option:

  • Give the following values in the variable box:
    • Name field - name
    • Email Address field - email
    • Comments field - mess
  • For all the three fields make sure that the draw border and background option is checked and the do not include font outlines option in the properties is chosen.
  • Check the restrict text length to option for all fields and set the value for the name and email address fields to 50 and for the comments field set it to 255.
  • Double click the reset button and give the action script (actions tab):
        Set Variable: "name" = ""
         Set Variable: "email" = ""
         Set Variable: "mess" = ""

    Logic: This clears what ever has been entered in the boxes
  • Double click the Send button and give the action script:
         Set Variable: "iSuccess" = 0
        Load Variables ("GuestBookSendCode.asp", "", vars=GET)
         Set Variable: "submit" = True
         Set Variable: "y" = 0
         Play

    Logic: This sends the values entered to the ASP page, sets the counter variable 'y' to 0, sets a variable 'submit' to True (to represent that the form a has been submitted) and goes to the next frame (Counter) .

2. Making the Submit Counter Interfaces: Make the interface shown in Fig(b) on your right in the next frame after 'NewEntry'.

  • Give the frame the label: 'Counter' and place the action script that follows in the actions tab for the frame on double clicking it:
          Set Variable: "y" = y+1
          If (iSuccess = 1)
                Go to and Stop ("Success")
          Else If (y > 100)
                Go to and Stop ("Failed")
          End If
    Logic: This increments the counter and depending on the value of the variable 'iSuccess' it goes to either the frame Success or Failed.
  • The two text fields should be right aligned and with different colors but same font size(to get a 3D digital display). You can of course use a single text field to make it easier for you.
  • Go to each of their properties tab by right clicking on them. Give the variable name as 'y' which as mentioned above is our counter variable.
  • Also, in their properties tab check the disable editing and disable selection options.



Fig(a): Input Form

 

 

 


Fig(b): Counter Frame

  • Make the two interfaces shown below in two adjacent frames. (You will need only the 'Successful', 'Error-Failed' texts shown and the two buttons (Return and Exit). The buttons can be programmed later when we put the whole Guest-Book together. Double click the frames one by one and give the labels:'Success' and 'Failed' respectively and in the actions tab give the action 'Stop'.

Fig(c & d): Successful and Failed Frames

Getting the Flash form to work

Making the Counter Work : Carry out the following steps to accomplish this:

Now your Flash file should appear as shown below. You have now finished the Flash interface for sending data to the database. Export your file as 'guestbook.swf' to an appropriate folder. Now create a new ASP file called 'GuestBook.asp' and place the guestbook.swf file in it.

ASP Gets the Data from the Database

Connecting to the Database and inserting data into it through ASP

<% '---------------This file is the GuestBookSendCode.asp file-------------------------

'Start Declaring all variable used by you (you can do this as you code)
Dim DBConn, strDB, strDate,strInsertSQL, strName, strEmail, strMess

'Give the Database Connection String
strDB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("dbGuestbook.mdb") & ";DefaultDir=" & Server.MapPath(".") & ";DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5"

'Get today's Date and the data sent from Flash (Replace is used to replace a ' with '' (2 quotes together) because a database doesn't allow insertion of strings with a single ' )
strDate=CDate(Date)
strName=Replace(request("name"), "'", "''")
strEmail=Replace(request("email"),"'", "''")
strMess=Replace(request("mess"), "'", "''")

'Give the SQL Insert Statement
strInsertSQL="Insert Into tblGuestBook (fldDate,fldName,fldEmail,fldMessage) Values ('" & strDate & "','" & strName & "','" & strEmail & "',' " & strMess & "' )"

'Open the database and insert
if strName<>"" and strEmail<>"" then
          Set DBConn = Server.CreateObject("ADODB.Connection")
          DBConn.Open strDB
          DBConn.execute strInsertSQL
          response.write "iSuccess=1" 'Send a success response to Flash
Else
          response.write "iFailed=1" 'Send a failed response coz' the name or/and email field was null.
End If

'Close the database connection
DBConn.close
Set DBConn=Nothing
%>   

Continue to Step 5A: Getting Data from the database to display in Flash


This tutorial covers the usage of ASP and Flash to bring about Flash dynamic data display and manipulation i.e. interactivity into Flash:

We would love to hear your comments and any suggestions on future tutorials we can add to this section. Thanks!

Fill the below form to submit your comments (or suggestions):
Bookmark and Share this web page.
Sponsored Link(s):
Beauty Templates | Business Templates | Christian Templates | CSS Templates | Education Templates | Family Templates | Flash Templates | Free Dreamweaver Templates
Food Templates | General Templates | Government Templates | Health/Medical Templates | Hi-Tech Templates | Kids/Childcare Templates | Low-cost Budget Templates
Personal Templates | Pets Templates | Photography Templates | Profession Templates | Real Estate Templates | Sports Templates | Telecom Templates | Travel Templates
Free Tutorials > Web Design Tutorials | CSS Web Design | Fireworks Tutorials | Dreamweaver Tutorials | Flash Tutorials | SEO Tutorials | Javascript Tutorials | PHP Tutorials