A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 49

Thread: am i doing the right thing? asp/flash

  1. #21
    say no more loydall's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    1,261
    Well,

    Your using sql to insert and read data from the database. sql isnt specific to asp - asp just uses it to do database stuff.

    in a normal sql insert you'd use something like

    insert into people(name, age)
    values ('bob','12')

    that makes sense right?

    in the asp we're also using variables in the insert that we grabbed the values for from the form - name and age. To stick these variables into the sql statement you have to build your statement around them.

    asp strings are contained like this "this is a string"

    you build strings by stringing them together (concatenating them) like this "this is a " & "string"


    This is how you put together your sql insert statement:


    sqlString = "values('" & someVariable & "','" & someothervariable..

    see? the single quotes are used in the sql statement and the double quotes define the string in the asp.


    Gimme a doughnut

  2. #22
    Senior Member
    Join Date
    Sep 2002
    Location
    Texas
    Posts
    348
    Nice work! You get double.
    Great minds think for themselves.

  3. #23
    Senior Member
    Join Date
    Sep 2002
    Location
    Texas
    Posts
    348
    Does the form have to be on the same page as the asp or can it be seperate?
    Great minds think for themselves.

  4. #24
    Senior Member
    Join Date
    Sep 2002
    Location
    Texas
    Posts
    348
    With this:

    Code:
    <%
    Session("DataConn_ConnectionString") = "DSN=mydsn" 
    
    set aaron = Server.CreateObject("ADODB.Recordset")
    
    FirstName = request.form ("name")
    
    
    strconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
    strconn=strconn & server.mappath("data.mdb") & ";"
    
    strSQL = "INSERT INTO data(FirstName) " 
    strSQL = strSQL & "Values('" & FirstName & "')"
    
    
    set conn = server.createobject("ADODB.Connection")
    conn.open strconn
    
    conn.execute(strSQL)
    
    conn.Close
    Set conn = Nothing 
    %>

    I get this:

    Microsoft JET Database Engine error '80004005'

    Operation must use an updateable query.

    /Test_Area/test.asp, line 19


    what does that mean? thanks!
    Great minds think for themselves.

  5. #25
    Senior Member
    Join Date
    Sep 2002
    Location
    Texas
    Posts
    348
    got it figured. had to change the permissions.
    Great minds think for themselves.

  6. #26
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    jesus where did all this come into it? i was sitting waiting on a reply to the thread and when i go look, theres all this, right i have to do some catching up!

  7. #27
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    http://imdasp.infj.ulst.ac.uk/stefan/test_2.asp

    nice one got that bit working! , i just realised i didnt have an ID field, but do now and it worked!

    whats next on the list now?
    Last edited by slinky2000; 02-28-2003 at 06:13 AM.

  8. #28
    say no more loydall's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    1,261
    Right,

    Just realised a small adjustment that you could make to your asp page that would make this thing whole thing a bit easier. Rather than having:

    response.write (dj.fields.Item("ID").Value)

    lets assume that you have the dj's info in a column called 'info' - replace the line above with:

    response.write (dj.fields.Item("info").Value)

    That way the asp file will output their name then a * then their info then a * and so on.

    Right - now the flash. The idea is that on frame 1 of layer 1 you load your variables into an instance of a movie clip that you have on the stage. Let's say the instance of your move clip is called 'getter' - 'cause it get's the data


    Anyway - first frame:
    loadVariables("http://imdasp.infj.ulst.ac.uk/stefan/test_2.asp", "getter");

    Now your movieClip will grab that data, split it up into an array using * - it goes something like this:

    onClipEvent (data) {

    MyArray = data.split("*");
    ButtonCount = MyArray.length;

    for (i=0; i<ButtonCount; i++) {



    Now lets say you've also created a movie clip that will be your repeated button. In linkage properties select Export for Actionscript and give it the name 'button'. Now attach it like this:

    _root.attachMovie("button", "button"+i, i);

    Stick it in it's own level:

    _root["button"+i].index = i;

    now, in the movie clip 'button', we've got a dynamic text field with the variable 'nam' - we send the first array element to that text field so it displays the users name:

    _root["button"+i].nam = MyArray[i];

    Then we also send another value to it - we'll call it 'inf' and it will be the next array element (i+1) which will (hopefully) be that persons info:
    _root["button"+i].inf = MyArray[i+1];

    You're having your buttons go down the side right? give each button it's coordinates, increase _y by whatever you want the spacing to be (the i*20 bit )


    _root["button"+i]._x = 20;
    _root["button"+i]._y = (i*20);

    now move past the info bit of the array so the the next element we come across is the next persons name:

    i++;
    }
    }

    Right that should have built made a load of buttons. Also on your stage your going to want a big dynamic text field that we'll give the variable name of text.

    Open up the movieClip we called button and stick a button in there and give it the following action:

    on (release) {
    _root.text = inf;
    }

    What that should do is display the dj's info (inf - remember we sent it to the clip earlier) in the big dynamic text field (text) on your stage.


    That's pretty much it - didn't even need that ID after all. Now - does it work?

    I have tried it and it does work (I've attached it to this message hopefully..)

    You might be wondering why I've gone into so much depth? Main reason, a dj friend of mine has asked me to build something very similar (oddly enough) - also I haven't actually built anything like this before so it's quite a good learning exercise - brushing up on my skills and all that.

    Oh yeah - the movie attached will only display the users ID at the moment until you change the asp page to display the info instead but should work just fine.

    Nice one.


    Last edited by loydall; 09-27-2008 at 12:12 PM.

  9. #29
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    ur a genious mate! works an absolute treat!

    http://imdasp.infj.ulst.ac.uk/stefan/djs.html


    i have to get a scroll bar workin now cos theres gonna be some 50+ buttons i imagine, it shouldnt be too hard hopefully, i think i can figure that one out for myself! thanks


    all as I have to do now is get a form for dj's to fill in that updates the database!

    think i can figure this one out aswell by myself aswell by what you've said, but if you wanna give me some help, feel free! lol


    mate u deserve a beer!


  10. #30
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    i even managed to put a scroll bar in myself! , lol, in flash 5 too!


    http://imdasp.infj.ulst.ac.uk/stefan/djs2.html

  11. #31
    say no more loydall's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    1,261
    mmmmmmmmmmmmmm scrolly.

  12. #32
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    hey mate once again!

    dont suppose you could help me on stage two!

    I need tos et up a little form that inputs the txt into the database,

    i only need two fields "Name" and "Info"


    can you help me out, please, your getting a mention when the site comes out!

  13. #33
    say no more loydall's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    1,261
    Right,

    This is pretty basic really - you could go into a bit more depth with this, checking the data loaded/didn't load etc but for now I reckon this will do the job.

    Fist thing - create a page in your stefan folder called insert.asp with the following code:


    <%

    name = request.form("name")
    info = request.form("info")


    strconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
    strconn=strconn & server.mappath("data.mdb") & ";"


    strSQL = "INSERT INTO people(name,info) "
    strSQL = strSQL & "Values('" & name & "','" & info & "')"


    set conn = server.createobject("ADODB.Connection")
    conn.open strconn

    conn.execute(strSQL)

    conn.Close
    Set conn = Nothing

    %>

    I can't remember if that was the correct connection string - if it isn't, change it to what you had working before.

    I've also assumed that it was the same database - data.mdb and the table was called 'people'

    Now - in your flash file you're going to need to create two input text boxes and give them the variable names 'name' and 'info'

    You'll also need to create a button and give it the following code:


    on (release) {
    loadVariables("http://imdasp.infj.ulst.ac.uk/stefan/insert.asp", "", "POST");
    }


    That's pretty much it - it should work just like that. The only thing is that when you press the button, it will insert the data but wont look like it's done anything so you might want to tell your movie to go to a frame saying 'Thanks for your info' or whatever - just to make it a bit more user friendly.

    Let me know if you get it working...

  14. #34
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    that works mate, cheers,

    i was tryin to do it myself, with the code u posted before for the pther dude, but for some readon it wasnt updating for me, but its workin now

    thanks alot!


    heres it here:

    http://imdasp.infj.ulst.ac.uk/stefan/input.html


    and you can see it updated here:

    http://imdasp.infj.ulst.ac.uk/stefan/djs2.html

    happy days!
    Last edited by slinky2000; 03-10-2003 at 08:57 AM.

  15. #35
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    another little thing mate, ive noticed that the max length of data a field can hold is 255 characters! Is there a way around this to get something a bit longer about 1000? of is it just a case of making 2 fields in the database?

  16. #36
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    ok doesnt matter!, just change the field from "text" to "memo"! simple! happy days!

  17. #37
    say no more loydall's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    1,261
    Yeah - I was going to mention that - just go into design view on your table (right click - select design view) and change the datatype for your field from text to memo. That will give loads more space for text than before (cant remember what the max characters is but it's loads...). It's also worth making sure that 'Allow zero length' in the properties box undeneath is set to 'Yes' - that way you wont get any errors if you try to submit an empty field.



    *edit* ah - you're too quick mate!

  18. #38
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    lol, hehe! beat you too it!, lol

    heres a little updated version to scroll the text aswell!

    http://imdasp.infj.ulst.ac.uk/stefan/test_djs2.html

  19. #39
    Slinky Designs slinky2000's Avatar
    Join Date
    Jun 2001
    Location
    Ireland
    Posts
    1,227
    alrighty then! stage 3!


    maybe im pushing my luck with this! but

    1. I know I can store an image in access, but how can i load it up into flash when one of the buttons are clicked,


    2. and possibly another thing im pushing my luck with is can i get the person "inputter" to upload an image of themselves onto myserver? or for the "inputter" to give me a url of an image of themselves and put that into a database and display it through that way?

    thanks mate, if you can do this it would be magic!

  20. #40
    say no more loydall's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    1,261
    He he he...


    Right - now we're really getting going....

    It is possible to let users upload files to your server but I can see a nunmber of reasons not to do it in this instance -
    firstly, I dont imagine your IT admin will allow users from outside to upload files to your server (You'd need to find that out though)

    Secondly - although storing images in access is possible - it might not be best in this situstion as we're going to be pulling images off it loads of times and access isn't super powerful. We also need to give flash a url to load the image from so we'd have to write out the image from the database to an asp page which is a bit unnesesary.

    Thirdly - Uploading files through ASP isn't as straightforward as the rest of this has been so would take some explaining. Having said that here's a decent enough tute/script that tells you all about it: http://www.asp101.com/articles/jacob/scriptupload.asp

    Anyway - the solution:

    First of all let's assume that you have a new column in your database called 'pic' - this will contain the full url to the image of the dj i.e http://www.somegeezerssite.com/myface.jpg

    Open up your asp page that writes out that long string. Underneath the last 'response.write "*"' you'll need to add:


    response.write (dj.fields.Item("pic").Value)

    response.write "*"


    And that should do it for that file.

    The flash bit:

    Not entirely sure how this works prior to flash mx but if you are using mx, it will work just fine:

    Open up your main .fla that you've been working on - Create a blank movie clip on the stage that will hold your images and give it the instance name of 'holder'.

    In your movie clip that has the data sent to it (I think we called it getter?) add:

    _root["button"+i].pic = MyArray[i+2];


    as we now have an extra element in the array you will need to move past two elements so change the last

    i++; bit to i = i +2;


    then open up the button movie and add a loadMovie to it so now you should have:

    on (release) {
    _root.text = inf;
    loadMovie(pic, "_root.holder");
    }


    What's happening here is that our third array element is the url to our image and we're loading it into our 'holder' movie clip.

    That kind of answers your question although you're going to have to ask dj's to either supply a url to a picture of themselves or get them to email it to you and then you can enter the url yourself.

    It's not ideal, I know, but without going into ASP upload's it's probably what you're going to have to do.

    ....if you do want to go into ASP upload though, let me know - I'll be writing an upload COM component at some point...




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center