PDA

View Full Version : Access Database MX and ASP



rlLife
May 4th, 2004, 05:08 PM
I will add the code for my database so you can see what is up. Everything works great, but I would like to make it have more features,except I can not for the life of me figure out how to add what I am looking for.

Right now flash calls apon the asp and the asp loads the database into flash. I have my mc's in flash numbered something like mc_0, mc_1. Then the data base loads field 1 into 1 and 2 into two.

What I would like to do is be able to switch it up without having to go into the database and move what i have in field two into field1, or field two info could move to field 20 if i wanted.

I currently am making an admin pannel for this site that will allow the client to upload photos and text to the database and this is were the problem came up.

In the news section, they always want the most current at the top, but the way it is set up now i would have to go into the flash file and move things around every week or the client would have to move all the different news items around so that most current is on top.

Thanks if you have any answers.

RL :ne:

rlLife
May 4th, 2004, 05:11 PM
Here is the code for the asp

<%
Option Explicit

Dim cn
Dim cmd
Dim rs
Dim cont

Set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "centerpointe"
cn.Open

Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
cmd.CommandText = "SELECT Headline, Intro, Story, AltStory, tn, fs, fswide, Altimage FROM MainTable"

Set rs = cmd.Execute
cont=0

Do Until rs.EOF
Response.Write "Headline"&cont&"="& rs("Headline") & "&" &"Intro"&cont&"="& rs("Intro") & "&" &"Story"&cont&"="& rs("Story") & "&" &"AltStory"&cont&"="& rs("AltStory") & "&" &"tn"&cont&"="& rs("tn") & "&" &"fs"&cont&"="& rs("fs") & "&" &"fswide"&cont&"="& rs("fswide") & "&" &"Altimage"&cont&"="& rs("Altimage") & "&"
cont = cont+1
rs.MoveNext
Loop

Response.Write "cant="&cont

rs.Close
cn.Close
%>

rlLife
May 4th, 2004, 05:12 PM
here is the AS



myData = new LoadVars();
myData.load("centerpointe.asp");
myData.ref = this;
myData.onLoad = function(succes){
if(succes){
for(var i=0; i<this.cant; i++){
this.ref["intro_txt"+i].html = true;
this.ref["intro_txt"+i].autoSize = true;
this.ref["intro_txt"+i].htmlText = this["Intro"+i];
this.ref["Story_txt"+i].html = true;
this.ref["Story_txt"+i].autoSize = true;
this.ref["Story_txt"+i].htmlText = this["Story"+i];
this.ref["AltStory_txt"+i].html = true;
this.ref["AltStory_txt"+i].autoSize = true;
this.ref["AltStory_txt"+i].htmlText = this["AltStory"+i];
this.ref["holder_mc"+i].loadMovie(this["tn"+i]);
this.ref["FS_holder_mc"+i].loadMovie(this["fs"+i]);
this.ref["wide_holder_mc"+i].loadMovie(this["fswide"+i]);
this.ref["Alt_holder_mc"+i].loadMovie(this["Altimage"+i]);
}
} else trace("Error loading data");
}
stop();

Movieclip.prototype.load_my_movies = function(moviename) {
loadMovieNum(moviename, 5);
unloadMovieNum(9);
unloadMovieNum(10);
unloadMovie(11);
};

Digitalosophy
May 4th, 2004, 07:07 PM
hmm this question looks familiar....

anywho.... you can select data and display it by using ORDER BY..


cmd.CommandText = "SELECT Headline, Intro, Story, AltStory, tn, fs, fswide, Altimage FROM MainTable ORDER BY ID DESC"


add an ID field to your database table, and make it autonumber. this will generate your data with the latest news events first.

in case you don't know what i mean take a look here.
http://www.w3schools.com/sql/sql_orderby.asp

rlLife
May 6th, 2004, 06:59 PM
that is what i was looking for, sorry i guess i might not have know what you were talking about in that past

rL

Digitalosophy
May 10th, 2004, 02:12 AM
cool, hope it worked out.

rlLife
May 10th, 2004, 02:29 PM
It did work our perfect, it is funny how I was able to set that whole stupid thing up and get it to work and just the small detail in the asp of (order by desc) was what i was missing. Thanks again for being soooooo smart.

rL::::

100th Post :D

Digitalosophy
May 10th, 2004, 03:38 PM
your very welcome...

btw you have a real cool site thuur ;)

rlLife
May 10th, 2004, 06:32 PM
Hey,
I have one more question for you, is it posible to do the same thing that i was just doing but use
<%=Intro("sub1")%>

Digitalosophy
May 10th, 2004, 06:36 PM
im sorry i don't follow. what are you trying to do?

rlLife
May 10th, 2004, 06:47 PM
yeh sorry, here is an example of how i am doing this in asp and html

<table width="207" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="top">
<td valign="top" align="center" width="88"><a href='<%=ListStoryURL("sub1")%>' target="_self"><img src='<%=ListImageTN("sub1")%>' width="68" height="68" border="0"></a></td>
<td width="119"><%=ListIntro("sub1")%> <br> <a href="<%=ListStoryURL("sub1")%>" target="_self">More...</a>
</td>
</tr>
</table>

I would love to be able to do something similar to this but in using flash.

rlLife
May 10th, 2004, 06:49 PM
and here is how i am connecting to the database in that example
<%
' FileName="Connection_ado_conn_string.htm"
' Type="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
MM_wccc_STRING = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=web3;database=wcccweb;UID=webpublis h;PWD=readonly"
'MM_wccc_STRING = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=ANVIL;database=wcccweb;UID=webpubli sh;PWD=readonly"
'MM_wccc_STRING = "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=DEV2;database=wcccweb;UID=sa;PWD=so lomon"
%>

Digitalosophy
May 10th, 2004, 06:53 PM
hmm ok so you want a record to be a hyperlink in flash.....

off the top of the head im having trouble with this... maybe i cant dabble a bit more later tonight for you...

edit: using dreamweaver eh?

rlLife
May 10th, 2004, 06:59 PM
yeh yeh using dreamweaver. No i really dont need to do the whole thing that was written in that table, what i need to do is just be able to have flash get this part of that whole thing
<%=Intro("sub1")%>

Digitalosophy
May 10th, 2004, 07:04 PM
oh ok well you can assign a variable to that



<% flashVar = Response.Write Intro("sub1") %>


and then make a textfield in flash with the variable name flashVar and load the variables from the page.

hope that helps

rlLife
May 11th, 2004, 12:02 PM
sorry i seem so dumb here but this whole database thing is new to me, do i put that code in flash or in the asp code?

rL

thanks for all our help

rlLife
May 11th, 2004, 12:15 PM
this look rrrright to you?

<%
Option Explicit

Dim cn
Dim cmd
Dim rs
Dim cont

Set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = "centerpointe"
cn.Open

Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = 1
cmd.CommandText = "SELECT Headline, Intro, Story, AltStory, tn, fs, fswide, Altimage FROM MainTable"

Set rs = cmd.Execute
cont=0

Do Until rs.EOF
flashVar = Response.Write Intro("sub1")
cont = cont+1
rs.MoveNext
Loop

Response.Write "cant="&cont

rs.Close
cn.Close
%>