-
say no more
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
-
Nice work! You get double.
Great minds think for themselves.
-
Does the form have to be on the same page as the asp or can it be seperate?
Great minds think for themselves.
-
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.
-
got it figured. had to change the permissions.
Great minds think for themselves.
-
Slinky Designs
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!
-
Slinky Designs
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.
-
say no more
-
Slinky Designs
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!
-
Slinky Designs
i even managed to put a scroll bar in myself! , lol, in flash 5 too!
http://imdasp.infj.ulst.ac.uk/stefan/djs2.html
-
say no more
-
Slinky Designs
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!
-
say no more
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...
-
Slinky Designs
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.
-
Slinky Designs
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?
-
Slinky Designs
ok doesnt matter!, just change the field from "text" to "memo"! simple! happy days!
-
say no more
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!
-
Slinky Designs
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
-
Slinky Designs
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!
-
say no more
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|