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

Getting Data from the database into Flash

ASP gets the data from the database and sends it to your Flash interface

In this step of our Flash and ASP integration guide, ASP interacts with the database and sends the required data for display to the Flash display form. This section is divided into two parts:

  1. The ASP page interacts with the Database and gets the required data
  2. ASP sends the retrieved data to Flash

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

ASP Gets the Data from the Database

Connecting to the Database and getting data from it through ASP

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

'Start Declaring all variable used by you (you can do this as you blue)
Dim DBConn, strDB, rsGuestBook, x, intSize, strSelectSQL, strDate, fldName, fldEmail, fldMess, fldDate, intPage, intStart, intFinish, intCount, intPageCount, intRecord, intNav,blnSubmit

'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 give the number of entries you would like to load per batch
strDate=CDate(Date)
intSize=50

'Get the variable to determine if a submission has been made
blnSubmit=request("submit")

'Get the Batch Number of the Guest-Book entries
intNav=request.QueryString("NAV")
if intNav = "" then intPage = 1 else intPage = cint(intNav)

'Give the SQL Select Statement
strSelectSQL="SELECT fldName, fldEmail, fldMessage, fldDate FROM tblGuestBook ORDER BY fldDate DESC , fldGID DESC"

'Create the Recordset with Read Only - Static (Forward and Backward Cursor) properties
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open strDB
set rsGuestBook=Server.CreateObject("ADODB.Recordset")
rsGuestBook.ActiveConnection = DBConn
rsGuestBook.Source = strSelectSQL
rsGuestBook.CursorType = 3
rsGuestBook.CursorLocation = 3
rsGuestBook.LockType = 1
rsGuestBook.Open

'The recordset is paged for optimization of the code
rsGuestBook.PageSize = intSize
rsGuestBook.CacheSize = intSize
intPageCount = rsGuestBook.PageCount
intCount = rsGuestBook.RecordCount
Set rsGuestBook.ActiveConnection = Nothing

If (not rsGuestBook.EOF) then
       rsGuestBook.AbsolutePage = intPage
       intStart = rsGuestBook.AbsolutePosition
End if

if CInt(intPage) = CInt(intPageCount) then
       intFinish = intCount
else
       intFinish = intStart + (rsGuestBook.PageSize - 1)
end if

%>   

ASP Send the Data to Flash

Supplying Data to the Flash Interface by the ASP file

<% '---------------Output the Data in the 'Variable-Value' format-----------------

response.write "&size=" & intSize & "&count=" & intCount "
if intCount=0 then response.write "&f_name=No Guest Entries Yet"

'The Flash interface needs an Initial Value for displaying the first record
if not rsGuestBook.Eof then
      if blnSubmit="True" then rsGuestBook.Movenext
      if not rsGuestBook.Eof then
             set fldDate=rsGuestBook("fldDate")
             set fldName=rsGuestBook("fldName")
             set fldEmail=rsGuestBook("fldEmail")
             set fldMess=rsGuestBook("fldMessage")
             response.write "&startN=" & fldName & "&startE=" & fldEmail & "&startM=" & fldMess & "&startD=" & fldDate & "&date=" & strDate
             response.flush
       end if
end if

'Now output all the records, each with an identifying index, value 'x'
x = ((intPage-1)*intSize)+1

For intRecord = 1 to rsGuestBook.PageSize
       if rsGuestbook.EOF then Exit For
       response.write "&name" & x & "=" & fldName & "&email" & x & "=" & fldEmail & "&mess" & x & "=" &        fldMess & "&date" & x & "=" & fldDate
       x = x + 1
       response.flush
       rsGuestBook.Movenext
Next

'Now close the recordset and database connection. Also set them and the fields (that were set to values from fields in the recordset) to Nothing
rsGuestBook.Close
DBConn.Close
Set rsGuestBook = nothing
Set fldName=nothing
Set fldEmail=nothing
Set fldMess=nothing
Set DBConn = nothing

%>   

Congratulations you have finished the ASP part of sending data to Flash.

Continue to Step 5B: Flash Displays the Data


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