ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 24th, 2003, 02:58 PM
melb melb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 5 melb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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
%>

Reply With Quote
  #2  
Old April 24th, 2003, 05:32 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
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.

Reply With Quote
  #3  
Old April 24th, 2003, 06:07 PM
melb melb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 5 melb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #4  
Old April 24th, 2003, 08:31 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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 '&'
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #5  
Old April 24th, 2003, 09:52 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
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.

Reply With Quote
  #6  
Old April 25th, 2003, 03:58 PM
melb melb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 5 melb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #7  
Old April 25th, 2003, 04:00 PM
melb melb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 5 melb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #8  
Old April 25th, 2003, 04:53 PM
numbernine numbernine is offline
Up To His Eyes In Ads
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Chicago
Posts: 160 numbernine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 6
How is Flash passing the variables to the ASP via GET or POST?
Are you sure that these variables are getting passed?

Reply With Quote
  #9  
Old April 25th, 2003, 05:14 PM
melb melb is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 5 melb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

%>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > basic asp/flash query with WHERE AND in SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT