|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
basic asp/flash query with WHERE AND in SQL
hi
I am brand new using Flash and ASP. Most of my experience is in Cold Fusion, but I suppose we all have to start somewhere ![]() I have been all over the internet and I think I have most of my answer. Thanks in advance for any advice you can offer- I need to grab info from the database using WHERE Building= (a variable in a string sent from Flash) AND BoothNum=(a variable in a string sent from Flash) Once the query runs, then the ASP page turns the selected info into a URL type string ready for Flash to grab Can someone take a look at my ASP, because I started out with someone elses script from a book, got it working, added an AND to my WHERE statement and I now am getting a too few parameters error on line 21, probably because I dont understand the 2, 3 parameters the original author gave for the open connection command? ASP Code is as follows: <%@Language="VBScript"%> <% ' Declare recordset and connection objects, ' SQL String. Dim ORs, oConn, strSQL ' Delcare VDS. Dim strVDS ' Get Building and BoothNum from Request. Dim Building Building = Request("Building") Dim BoothNum BoothNum = Request("BoothNum") ' Create recordset and connection objects. Set oConn = Server.CreateObject("ADODB.Connection") Set oRS = Server.CreateObject("ADODB.Recordset") oConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DBQ=" & Server.MapPath("mate.mdb") oConn.Open strSQL = "SELECT * FROM Exhibitor WHERE Building = " & Building strSQL = strSQL & " AND BoothNum = " & BoothNum oRS.Open strSQL, oConn, 2, 3 ' Check for invalid Building and BoothNum. If oRS.EOF Then strVDS = "success=False" Else strVDS = "success=True" ' Build the Variable String. strVDS = strVDS & "&ID=" & Server.URLEncode(oRS("ID")) & _ "&Company=" & Server.URLEncode(oRS("Company")) & _ "&Building=" & Server.URLEncode(oRS("Building")) & _ "&BoothNum=" & Server.URLEncode(oRS("BoothNum")) & _ "&EquipDesc=" & Server.URLEncode(oRS("EquipDesc")) & _ "&BoothPage=" & Server.URLEncode(oRS("BoothPage")) & _ "&BoothUpgrade=" & Server.URLEncode(oRS("BoothUpgrade")) End If Response.Write strVDS oRS.Close Set oRS = Nothing oCOnn.Close Set oConn = Nothing %> |
|
#2
|
|||
|
|||
|
Too few parameters usually refers to your SQL Statement; as I recall, usually from field names that don't exist in the database. Try printing out your SQL and running that against the database manually.
|
|
#3
|
|||
|
|||
|
nope those are definetely my field names.
i think there's something wrong with my SQL statement. i really don't know much about ASP and haven't been able to find any examples of querying with WHERE and an AND in this situation. Maybe you could take a look at my SQL statement and see if you see anything weird there? I have tried it as all one statement, but it gives me syntax errors. What do you think? |
|
#4
|
||||
|
||||
|
when passing parameters through the querystring, the first one must start with a '?'.
By the looks if it, your strVDS var starts off with a '&' |
|
#5
|
|||
|
|||
|
Are Building and BoothNo both number values? Because if not, you need to enclose them in single quotes in the SQL Statement. i.e.
Code:
SELECT * FROM myTable WHERE Building = 'Building7' NOT Code:
SELECT * FROM myTable WHERE Building = Building7 In the second case it would interpret "Building7" as being a field name even though you intended it as a variable. |
|
#6
|
|||
|
|||
|
hmm well i changed my SQL statement
and my error is gone, but it doesn't pull up the record i request. it just returns the very first record in the db never thought this little SQL statement would be such a toughy. |
|
#7
|
|||
|
|||
|
stumpy- thanks for the reply,
but but question mark is in my link in my Flash movie so i think my problem lies elsewhere any other ideas? |
|
#8
|
|||
|
|||
|
How is Flash passing the variables to the ASP via GET or POST?
Are you sure that these variables are getting passed? |
|
#9
|
|||
|
|||
|
well- here's the code for my page that I started with-
(grabs the Exhibitors depending on their ID) It works great. But as I said my new ASP page with my Building=&BoothNum= doesn't work. Should it matter if my Flash movie is getting the variables passed if my ASP script doesn't work on its own? Thanks for all your help BTW Code On My Button- on (rollOver) { CurrentRecord = 0; loadVariables ("getexhibitors.asp?Record=0", this); } on (rollOut) { strLName = ""; strFName = ""; strID = ""; strCompany = ""; } Code on My MovieClip onClipEvent(data) { strLName = LName; strFName = FName; strID = ID; strCompany = Company; strPosition = "Record " add String(CurrentRecord+1) add " of " add String(TotalRecords); } onClipEvent(load) { CurrentRecord = 0; } Code for My ASP <% Set DataConn = Server.CreateObject("ADODB.Connection") DataConn.Open "Driver=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("MATE.mdb") Set cmdTemp = Server.CreateObject("ADODB.Command") Set rstExhibitor = Server.CreateObject("ADODB.Recordset") cmdTemp.CommandText = "Select * From Exhibitor" cmdTemp.CommandType = 1 Set cmdTemp.ActiveConnection = DataConn rstExhibitor.Open cmdTemp, , 1, 3 rstExhibitor.Move CLng(Request("ID")) Response.write "ID=" & Server.URLEncode(rstExhibitor("ID")) & "&" Response.write "FName=" & Server.URLEncode(rstExhibitor("FName")) & "&" Response.write "LName=" & Server.URLEncode(rstExhibitor("LName")) & "&" Response.write "Company=" & Server.URLEncode(rstExhibitor("Company")) & "&" Response.write "TotalRecords=" & rstExhibitor.RecordCount rstExhibitor.Close DataConn.Close %> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > basic asp/flash query with WHERE AND in SQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|