View Full Version : Question about sending large strings to Database
zephyr
01-12-2003, 07:05 PM
Hi
I am trying to send three large strings to a database by using this line: loadVariables("PositionsAdd.asp?xpos="+strXpos+"&ypos="+strYpos+"&rpos="+strRpos, mcCheck, "POST");
It works fine but when the lenght of each string gets over about 140 characters it dosent work, but up till about 135 chars it works fine?
Is there a limit of size of this string, and do you know how I can avoid this problem
Thanks in advance
Zephyr
freddycodes
01-12-2003, 07:50 PM
You could try building an XML object and sendin that to ASP. Are you using Flash MX or 5? Can you show a sample of what these string look like and I can try to help you further. Also even though you specify the method of transport as "POST" you are actually using GET because you are appending the data to the query string. And yes there is a character limit when using GET. Yo ucan achieve POSt by using. Yo ucan achieve this using Xml quite easily or using Flash MX.
zephyr
01-12-2003, 10:19 PM
Hi Freddycodes
Im using Mx, I have set it to "POST" because it didnt seem to work using "GET"
The strings are x- and y-coordinates and rotate.
It is used to record the movement of an object. The string looks like this: PositionsAdd.asp?xpos=143.25,143.25,143.25,143.25, 143.25,143.25&ypos=318.45,318.45,318.45,318.45,318.45,320.30&rpos=26,39,52,65,65,65"
but instead of 6 numbers per string I need there to be alot, because otherwise it wont be smooth. And in my first thread i said that it didnt work after 140 chars. that is not right it is after 140 counts * between 2 and 5 chars each and * three strings, so that is more like 1250 chars, altogether.
I hope You can help me on with this problem
If You have more questions just ask and I will try to answer
Thanks in advance
Zephyr
freddycodes
01-12-2003, 10:29 PM
Of course, using Flash MX we can take care of this no problem.
myPosVars = new LoadVars();
myPosVars.xpos = strXpos;
myPosVars.ypos = strYpos;
myPosVars.rpos = strRpos;
myPosVars.sendAndLoad("PositionsAdd.asp", this, "POST");
This little bit of code will actually post the values to the ASP script, like I said before whether you intended it or not by appending the values to the url you were in fact using the GET method.
Originally posted by zephyr
Hi
loadVariables("PositionsAdd.asp?xpos="+strXpos+"&ypos="+strYpos+"&rpos="+strRpos, mcCheck, "POST");
altho you use 'POST' in your action, you are actually sending the data thru the querystring (which is the method 'GET' uses). the query string limits the amount of data you can send.
freddycodes code should work perfectly for you.
zephyr
01-13-2003, 05:02 PM
Hi again
Hmm, I can see what you mean, but it dosent seem to work when I just insert it instead of the old loadvariables.
do I have to change anything in the .asp page?
Or am I missing something else?
Regards Zephyr
the asp looks like this:
-----
<%@Language="VBScript"%>
<%
if len(Request("xpos"))>0 AND len(Request("ypos"))>0 AND len(Request("rpos"))>0 Then
Dim RS, Conn
Set RS = Server.CreateObject("ADODB.Recordset")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("RaceCar.mdb")
Conn.Open
Dim SQL
SQL = "DELETE FROM Positions"
conn.Execute(SQL)
SQL = "INSERT INTO Positions (Xpos, Ypos, Rpos) VALUES ('"&Request("Xpos")&"','"&Request("Ypos")&"','"&Request("Rpos")&"')"
conn.Execute(SQL)
Response.redirect "Positions.asp"
Conn.Close
Set Conn = Nothing
End if
%>
--------
freddycodes
01-13-2003, 06:14 PM
Response.redirect "Positions.asp"
What is this in here for? What is supposed to happen after the data is inserted?
freddycodes
01-13-2003, 06:42 PM
Also in this line
if len(Request("xpos"))>0 AND len(Request("ypos"))>0 AND len(Request("rpos"))>0 Then
Dim RS, Conn
You refer to the variables with all lowercase letters.
In the SQL statement you use mixed case.
SQL = "INSERT INTO Positions (Xpos, Ypos, Rpos) VALUES ('"&Request("Xpos")&"','"&Request("Ypos")&"','"&Request("Rpos")&"')"
See the difference?
Request("Xpos") vs Request("xpos")
zephyr
01-13-2003, 09:40 PM
Yes You are right about upper/lower case. I have correctet that now.
The Response.redirect "Positions.asp" is calling a asp page that gets the data from the base.
There are two asp pages one for inserting data into the base, and one for collecting it again.
I havent worked very much with asp so it was a friend who made the asp for me, and he dosent know alot about flash, so there probably is a smarter way of doing it than this.
freddycodes
01-13-2003, 09:43 PM
Yeah what data are you pulling out? Just put that part right after the insert stuff, don't use Response.Redirect. Since you want the data to make it back to flash.
zephyr
01-14-2003, 10:46 AM
The basic scenario is that I want to save positions (Xpos,Ypos,Rpos) in a database. Then another can get the information from the base and see the object move controled by the positions from the base. So it is just the same three positions which are send og load again.
And it is not nessesary to pull them now again right after they are saved.
When I use this actionscript:
myPosVars = new LoadVars();
myPosVars.Xpos = strXpos;
myPosVars.Ypos = strYpos;
myPosVars.Rpos = strRpos;
myPosVars.sendAndLoad("PositionsAdd.asp", this, "POST");
But then I use this wont the variables which are send from flash be called ex.:"myPosVars.Rpos" and the asp will be looking for variables called just:"Rpos" ?? Could that be the reason that it dosent work.
Im really new at this but I think that if I just get this to work right with both flash & asp, when I can get the hang of it and work on from there on my own.
It would be cool if You maybe could show me an actionscript that works and the asp page that it works with. Or if it is easier, just guide me on.
Thanks again
regards
Zephyr
nope, myPosVars is the object doing the sending. so that is not part of the name in asp...
with loadVariables, all variables on the current timeline are sent to the asp page, say your on the _root timeline, your vars in the asp page are not _root.xpos, the server just gets xpos. it works kinda the same way with loadVars... you'll just get the variable names.
zephyr
01-14-2003, 04:11 PM
Ok thats what I thought...But still it dosent work yet, and I have followed Your instructions. So Im still looking for further help, if possible. Thanks
Zephyr
freddycodes
01-14-2003, 04:22 PM
Can you tell me what exactly doesn't work? Is it not making it to the database? Does the asp Page work standalone, I mean if you fake it aput values for the variables at the top of the asp page, does it work. The flash side of things looks correct. Can you check on the asp side of things? I am looking as well.
zephyr
01-14-2003, 05:44 PM
well it never makes it to the database. Then I use the old line: loadVariables("PositionsAdd.asp?xpos="+strXpos+"&ypos="+strYpos+"&rpos="+strRpos, mcCheck, "POST"); It worked (with the limited string length) and I havent changed anything else. it seems like it is stalling when i push the send button with the new script.
I have added this for check:
myPosVars.onLoad = function(success) {
if (success) {
DbInterAction = "Send-Fine";
} else {
DbInterAction = "Send-Wrong";
}
}
And it dosent show either "Send-Fine" or "Send-Wrong" so Im lost. and like I said before; I dont know very much about asp so it is hard to figure out, if it is the asp-script that wrong.
I have just checked the asp page by typing this: PositionsAdd.asp?Xpos=103&ypos=53&rpos=25 and that works fine.
/zephyr
freddycodes
01-14-2003, 05:45 PM
Okay I think one of the problems was in the line
myPosVars.sendAndLoad("PositionsAdd.asp", this, "POST");
It should have been
myPosVars.sendAndLoad("PositionsAdd.asp", myPosVars, "POST");
I got it all working. One thing the user running IIS must have write permissions to the folder containing the access database.
zephyr
01-14-2003, 06:11 PM
IT WORKS PERFECTLY !! I've pasted it to my own script and just works fine !!!
Super !
Thanks alot for your time !
Best Regards
Zephyr
zephyr
01-14-2003, 07:08 PM
Hi again
I was a bit to quick before, It works fine sending and i thought that it worked loading too. but it dosent this it the asp-page I have been using for loading :
-------------
<%@Language="VBScript"%>
<%
Dim RS, Conn
Set RS = Server.CreateObject("ADODB.Recordset")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("RaceCar.mdb")
Conn.Open
RS.Open "SELECT * FROM Positions ORDER BY posID", Conn, 2, 3
if not RS.EOF OR RS.BOF Then
Dim Counter
Counter = 1
While not RS.EOF
Response.Write "Xpos"&Counter&"=" & Server.URLEncode(RS("Xpos")) & "&Ypos"&Counter&"=" & Server.URLEncode(RS("Ypos"))&"&Rpos"&Counter&"=" & Server.URLEncode(RS("Rpos"))
Counter = Counter + 1
RS.MoveNext
Wend
Else
Response.Write "No entries"
End if
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
--------------------
is it correct that i have to this in AS to load:
myPosVars.load("Positions.asp");
Thanks Again
zephyr
zephyr
01-14-2003, 07:33 PM
Hi again again
I think I have made it work loading
Thanks again
Zephyr
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.