Ask a Question related to Macromedia Flash Data Integration, Design and Development.
-
Lyndsey21 #1
Flash front quiz/ asp and sql server. Connectionproblem.
Hi. I am following an example from a book that shows you how to create a flash
front end quiz with asp.net and sql server databse. I am using flash MX 2004,
visual basic 2003 & MS SQL server 2000. I am having problem connecting the user
registration from the flash end. It just doesn't seem to do anything even
though I have copied the code exactly as it says in the book(Building database
driven flash application).
The user choose to register and enters their username and password then clicks
a register button. this then goes to another frame that has a movie clip and
the following code behind it:
onClipEvent(load) {
_root.done = 0;
//call aspx page to register new player
_root.loadVariables("Register.aspx?PlayerName="+_r oot.strUsername+"&Password="
+_root.str
Password);
startTime = getTimer();
}
onClipEvent(enterFrame) {
//check for timeout
if ((getTimer() - startTime)/1000 < _root.TimeoutLength) {
if (_root.done=="1") {
//if aspx returned an error send to error screen
if (_root.Error != "") {
_root.strReturn = "initialize2";
_root.gotoAndStop("error");
} else {
//if all is successful sent to question
_root.gotoAndStop("question");
}
}
} else {
_root.error = "The server timed out while trying to register your
information. Please press OK below to try again.";
_root.strReturn = "register";
_root.gotoAndStop("error");
}
}
In the register aspx page that it calls the code is as follows:
Public Class Register
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim objCMD As New SqlClient.SqlCommand
Dim objConn As New SqlClient.SqlConnection
Dim objDR As SqlClient.SqlDataReader
Dim strSQL As String
Dim blnResult As Boolean
Response.Write("dummy=1")
' Set the connection
objConn.ConnectionString = Application("strConn")
' Open the connection
objConn.Open()
' Set the command connection
objCMD.Connection = objConn
' See if an existing player with the same name exists
strSQL = "select idPlayer from Players where PlayerName= '" & _
Replace(Request.QueryString("PlayerName"), "'", "''") & "'"
' Set the command query
objCMD.CommandText = strSQL
' Set the reader
objDR = objCMD.ExecuteReader
' Get the data and see if anything is returned
blnResult = objDR.Read
' If no data returned
If blnResult = False Then
' Build a SQL statement to insert the new player
strSQL = "insert into Players(PlayerName, Password) values('" & _
Request.QueryString("PlayerName") & "', '" & _
Request.QueryString("Password") & "')"
' Set the command query
objCMD.CommandText = strSQL
' Close the reader
objDR.Close()
' Execute the query
objCMD.ExecuteNonQuery()
strSQL = "select idPlayer from Players where PlayerName= '" & _
Replace(Request.QueryString("PlayerName"), "'", "''") & _
"' and Password = '" & _
Replace(Request.QueryString("Password"), "'", "''") & "'"
' Set the command query
objCMD.CommandText = strSQL
' Set the reader
objDR = objCMD.ExecuteReader
' Get the result of the read
blnResult = objDR.Read
' If no results, then there is no player match
If blnResult = False Then
Response.Write("&Error=There was an error registering " & _
"your information.")
Else
' There is a match, store the player ID and
' send the user to the triva home page
Session("idPlayer") = objDR.Item("idPlayer")
End If
Else
' Indicate there is a user with the name already
Response.Write("&Error=The Player Name you selected " & _
"has already been taken.")
End If
Response.Write("&done=1")
End Sub
End Class
The flash movie is embeded into a page called default.aspx
Can any see anything major that im doing wrong here? Maybe there is some sort
of problem with the flash accessing the asp pages. I am not sure. I am new to
this and finding it difficult. Hope someone can help me. Thanks In advance.
Lyndsey x
onClipEvent(load) {
_root.done = 0;
//call aspx page to register new player
_root.loadVariables("Register.aspx?PlayerName="+_r oot.strUsername+"&Password="
+_root.str
Password);
startTime = getTimer();
}
onClipEvent(enterFrame) {
//check for timeout
if ((getTimer() - startTime)/1000 < _root.TimeoutLength) {
if (_root.done=="1") {
//if aspx returned an error send to error screen
if (_root.Error != "") {
_root.strReturn = "initialize2";
_root.gotoAndStop("error");
} else {
//if all is successful sent to question
_root.gotoAndStop("question");
}
}
} else {
_root.error = "The server timed out while trying to register your
information. Please press OK below to try again.";
_root.strReturn = "register";
_root.gotoAndStop("error");
}
}
Lyndsey21 Guest
-
flash coldfusion quiz
I've been looking into the Flash 8 quiz template and it looks good. It is exactly what I need for a quick eLearning site. I won't need drop and drag... -
Flash media server for multi-user quiz game
Hi Friends, I am planning use the flash media server and flash remoting to host a multi-user quiz game which will be played globally. I would... -
Flash Quiz Templates
THe is no way to do it for Checkboxes. Check out: Using Macromedia Flash MX learning interactions Once there, you'll need to download the PDF.... -
Flash Quiz Trouble
I created a quiz using Flash MX 2004 on my MacIntosh. When I tested it on my computer it worked fine. The problem is that it doesn't work, more... -
Front Page Server Extensions
Can someone please help me up load front page server extensions to my ISP. I can't even use submit buttons until this is done. Any help would be...



Reply With Quote

