Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP to MySQL 1

Status
Not open for further replies.

triquad

Programmer
Feb 5, 2009
16
EG
Hello .. I'm trying to develop an online trivia game using Flash. Everything is going fine. I have used a tutorial & added some new features but currently I'm having a problem which is the trivia questions & answers are loaded from ASP.NET databases. Actually, I know nothing about ASP.NET. I don't know how to use it to make databases & to load data from them. I use PHP & MySQL. My question is how can I use MySQL instead of ASP.NET to load the data (if possible). If not .. then can you provide me with some tutorials on how to make it in ASP.NET & the server requirements.

The data is loaded like the examples below:

Code:
varSomeVariable.load("[URL unfurl="true"]http://www.yourdomain.com/somedirectory/getthedata.aspx");[/URL]

varTriviaSend.sendAndLoad("[URL unfurl="true"]http://www.yourdomain.com/somedirectory/getthedata.aspx",varReceivetheData,"GET");[/URL]

[URL unfurl="true"]http://www.yourdomain.com/somedirectory/getthedata.aspx?SomeNum=5[/URL]

As you may notice, the data is loaded through a url which is not the case when you use MySQL. I'm somehow confused. What do you think ?
 
1. what is the code above? php, c#, flash?
if you are getting data via web request, then how the aspx page gets the data is irrelevant to you client code above. I you also need to write the aspx page, then you need to learn webforms before you start slinging code.

2. asp.net simply serves http requests/responses, nothing more. this framework is what makes webforms, monorail and ms mvc possible.

3. asp.net has nothing to do with database access. the ado.net components (which are part of the .net framework) are responsible for querying a database. as long as the database has an odbc connection you can access it.

here is another comparison
.net ~ php
ado.net ~ PEAR DAL
webforms ~ smarty html template engine

notice above I don't state asp.net ~ smarty. that's because asp.net just serves requests, it has nothing to do with rendering html. this difference has never been explained well and why most .net web developers find asp.net and webforms synonymous.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you very much for your explaination.

1. The code above is ActionScript 2.0
Unlike the other applications when you need an external php file to contact the MySQL database, this flash file have only the ActionScript codes that calls the questions & answers through the links I mentioned above.

I will type below part of the tutorial that explains how the process of calling the questions & answers is done.

Database tutorial description:
]All of the questions are pulled into the application from a web application driven by a database backend. The questions are randomly selected by the application. An array is used to keep track of the user’s answered questions to be sure they don’t get the same question twice.

You can set your application up to pull data from the application provided on the tutorial web site by using the address shown in the code below. This application interacts with the external data application by loading the questions as needed. This keeps the amount of data loaded to a minimum which helps boost the speed of the application. You can view the FlashDBTrivia.txt file to see the initial data loaded, which is just a count of the number of questions in the database. Then if you open the FlashDBTrivia2.txt file, you’ll see what happens when a question is requested from the data application. Both of those files are included in the ZIP package created for this tutorial. These files are formatted properly for use in Flash files as the data has been URL encoded by the application.


As noted above, the application loads data from a web application. You can see the data returned at the following address:
As you can see, the data is URL encoded so that it can be properly imported into Flash. The first link will pull the number of questions found in the database, held in the qCount variable. The second link is called when the application randomly chooses the next question to retrieve. The data includes currentQ, answerList, and correctList. An errorMsg element is included on each page as well. If an error occurs loading the data, the errorMsg variable will be populated. Otherwise, just the items listed above will be displayed on the respective pages. The answerList and correctList data lists are actually pipe-delimited (‘|’) lists that allow the application to quickly split the list of items into an array, using the split method of the array object in Flash. Again, since the application will continue to make calls to the database application, it needs to use the remote server demonstrated in the code below unless you develop and host your own application to retrieve the data.
If you wish to develop your own script, be sure that your application formats the data properly. For this application, I use ASP.NET to retrieve data from a multiple data tables. The database diagram for these tables is shown in Figure 1 below:


tdb.jpg



ActionScript:
Code:
The next block of code declares a variable to hold the number of questions in the application. We’ll also create a LoadVars object that will be used to get the number of questions found in the database:
//Determine the number of questions in the database
var numQCount:Number;
//Create trivia data receiver objects
var varTriviaCount:LoadVars = new LoadVars();
//Load the data from the external web application
varTriviaCount.load("[URL unfurl="true"]http://www.flashydata.com/flashydata/gettriviaquestioncount.aspx");[/URL]


Code:
//Load the data from the external web application
varTriviaSend.questionNum = numRandomQ;
//varTriviaSend.send("[URL unfurl="true"]http://www.yourdomain.com/somedirectory/getthedata.aspx","_blank","GET");[/URL]
varTriviaSend.sendAndLoad("[URL unfurl="true"]http://www.yourdomain.com/somedirectory/getthedata.aspx",varTriviaReceive,"GET");[/URL]


FlashDBTrivia.txt
Code:
qCount=30&errorMsg=

FlashDBTrivia2.txt
Code:
currentQ=What+is+the+name+of+your+team+that+plays+in+the%2c+arena%3f&answerList=white+wings%7cFridays%7cLions%7cLizards&correctList=1%7c0%7c0%7c0&errorMsg=

I think that's everything. Can you explain how can I make it work with my own DB ? Thank you for your time.
 
this depends if you have access to modify the project/solution. I'm under the impression that the trivia application is a 3rd party project. If so you should contact the support staff for that product on how to modify the database connectivity.

if this is your project solution (or inherited from a previous developer) then you have two options.

1. change the connection string and provider values in the web.config file. no code changes! this assumes they utilized the full OOP potential of ado.net. no

2. open the source files and find all the references to [X]Connection object. where [X] is Sql, Oracel, OleDb, etc.

for more assistance on the connection string syntax check out
Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Well, it's not what you got.

The tutorial gives you access to their database through the ASP link for you to test your trivia for the 1st time. But later when you finish testing that everything is working fine, you should make your own database & your own ASP file. The problem is that they didn't mention how to make your own ASP file to connect the database to the flash trivia. As you may noticed from my previous posts, I didn't know what ASP is & of course I didn't use it before. After reading some articles online, I got the idea that ASP works as an intermediate between the database & flash in order to display the questions & answers correctly. Now the problem is that I don't know how to make the ASP file..!
 
I got the idea that ASP works as an intermediate between the database & flash in order to display the questions & answers correctly.
this is how you are using it, but it is not what asp.net is.

btw, asp and asp.net are two distinct languages. asp is a scripting language and asp.net is a compiled OOP language.

asp.net is a framework to service http request. webforms is an html template engine (and a poor one at that).

when you flash file calls domain.com/directory/page.aspx it's just a uri. it could have any extension/path. the server is responsible for processing the command associated with the uri. this is true of all web development languages: asp.net, ruby, php, cgi.

if this trivia product you are using is tell you to recode the system for production, then you might as well drop asp.net all together and use a language (php) that you are comfortable with.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I'm trying now to develop the .php file which handles the whole process of connecting flash to MySQL DB instead of using ASP.NET. I think it's not an ASP.NET issue anymore, that's why I think I'm done with this thread. If I want to ask later, I think I should do that in the PHP section.

Thank you a lot for your time & effort. Much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top