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: 8
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
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
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 '&'

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: 8
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: 8
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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek