View your Shopping CartFrequently Asked QuestionsEmail Us
Home | About Us | Contact Us
SmartWebby.com provides best web design & web programming services globally
We specialize in Rapid Web Design, ASP.net, ASP and PHP web programmingBest Web Design, Best Web Programming, Global Service Provider - Dependable Professionals to build your website right!

Flash and ASP Integration - ASP gets & sends the data to Flash

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

%>   

 

Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!

FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!

Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization