Hello! I'm new to this forum and also new to using ASP and SQL and Access. I am in need of some help. I'm trying to make a database to help my football team. I've pretty much got the whole thing done to where a coach can enter new games and various plays within those games. Now I've reached the hard part.
I need to make a process page that will help me query the database given varying situations. Below is an image of the page that the query will reside on.
I've removed the rights so you can go to the actual page at http://www.clintpatterson.com/Eagle_Db2/Admin/Db_Query.asp
Below is my startings of a process page, but I don't know how to make it actually work and my syntax is all off. Do you guys have any insight into something that could help?
Thanks -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
-
<%
-
-
-
' defines page from which information is coming
-
<form method="get" action="Db_Query.asp">
-
-
-
'Variable listed below here
-
'--------------------------------------------------------------------
-
-
Results_Page = "db_query_results.asp"
-
-
Dim VarGame_Title = request.form("Game_Title")
-
Dim VarFormation = request.form("Formation")
-
Dim VarDown = request.form("Down")
-
Dim VarDistance_Symbol = request.form("Distance_Symbol")
-
Dim VarDistance = request.form("Distance")
-
Dim VarHash = request.form("Hash")
-
Dim VarStrength = request.form("Strength")
-
Dim VarGain_Loss = request.form("Gain_Loss")
-
Dim VarBench = request.form("Bench")
-
Dim VarResult = request.form("Result")
-
-
-
if VarGame_Title <> "" then
-
sqlst = sqlst + "Game_Title =" + VarGame_Title
-
endif
-
-
if VarFormation <> "" then
-
sqlst = sqlst + "Formation =" + VarFormation
-
endif
-
-
if VarDown <> "" then
-
sqlst = sqlst + "Down =" + VarDown
-
endif
-
-
if VarDistance_Symbol = "none" then
-
sqlst = sqlst + "Distance_Symbol =" + VarDistance_Symbol
-
elseif VarDistance_Symbol = ">" then
-
sqlst = sqlst + ">"
-
elseif VarDistance_Symbol = "<" then
-
sqlst = sqlst + "<"
-
elseif VarDistance_Symbol = "=" then
-
sqlst = sqlst + "=" then
-
elseif VarDistance_Symbol = ">=" then
-
sqlst = sqlst + ">="
-
elseif VarDistance_Symbol = "<=" then
-
sqlst = sqlst + "<="
-
endif
-
-
if VarDistance <> "" then
-
sqlst = sqlst + "Distance =" + VarDistance
-
endif
-
-
if VarHash <> "" then
-
sqlst = sqlst + "Hash =" + VarHash
-
endif
-
-
if VarStrength <> "" then
-
sqlst = sqlst + "Strength =" + VarStrength
-
endif
-
-
if VarGain_Loss <> "" then
-
sqlst = sqlst + "Gain_Loss =" + VarGain_Loss
-
endif
-
-
if VarBench <> "" then
-
sqlst = sqlst + "Bench =" + VarBench
-
endif
-
-
if VarResult <> "" then
-
sqlst = sqlst + "Result =" + VarResult
-
endif
-
-
-
-
-
-
-
Response.Write(sqlst)
-
Response.Redirect(Results_Page)
-
-
%>
5 1811
pattersonc,
It looks like your approach is valid, but you are getting a lot of syntax errors and you are not sure how to clean them all up, right? first "end if" is two words. Second, don't try to declare a variable and assign it in the same line. Try this: - dim varA, varB, varC, varD
-
varA = request("A")
-
varB = request("C")
-
'etc.
try those and let me know how far you get.
Jared
I've made some progress with the help of a friend. He says I needed to include the connection and then do the response.write sqlst.
How does this work?
My new code is below... -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
-
-
-
<%
-
for x = 1 to Request.Form.count()
-
Response.Write(Request.Form.key(x) & " = ")
-
Response.Write(Request.Form.item(x) & "<br>")
-
next
-
%>
-
-
-
-
<%
-
'Variable listed below here
-
'--------------------------------------------------------------------
-
-
Results_Page = "db_query_results.asp" ' the page where results will be outputted
-
sqlst = "" 'sets main sql statement blank
-
-
'sets up variables in ASP from the submitted values of web page
-
Dim VarGame_Title, VarFormation, VarDown, VarDistance_Symbol, VarDistance, VarHash, VarStrength, VarGain_Loss, VarBench, VarResult, VarPlay, VarYardline
-
VarGame_Title = request.form("Game_Title")
-
VarFormation = request.form("Formation")
-
VarDown = request.form("Down")
-
VarDistance_Symbol = request.form("Distance_Symbol")
-
VarDistance = request.form("Distance")
-
VarHash = request.form("Hash")
-
VarStrength = request.form("Strength")
-
VarGain_Loss = request.form("Gain_Loss")
-
VarBench = request.form("Bench")
-
VarResult = request.form("Result")
-
VarPlay = request.Form("Play")
-
VarYardline = request.Form("Yardline")
-
%>
-
-
<%
-
If VarGame_Title <> "" Then
-
sqlst = sqlst & "Game_Title =" + VarGame_Title
-
End if
-
%>
-
-
<%
-
If VarFormation <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Formation =" + VarFormation
-
else
-
sqlst = sqlst & " AND Formation =" + VarFormation
-
End if
-
%>
-
-
<%
-
If VarDown <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Down =" + VarDown
-
else
-
sqlst = sqlst & " AND Down =" + VarDown
-
End if
-
%>
-
-
<%
-
If VarDistance <> "" Then
-
If VarDistance_Symbol = "Any" Then
-
sqlst = sqlst
-
else
-
if sqlst ="" then
-
sqlst = sqlst & "Distance"+ VarDistance_Symbol + VarDistance
-
else
-
sqlst = sqlst & " AND Distance" + VarDistance_Symbol + VarDistance
-
end if
-
end if
-
End if
-
%>
-
-
<%
-
If VarHash <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Hash =" + VarHash
-
else
-
sqlst = sqlst & " AND Hash =" + VarHash
-
End if
-
%>
-
-
<%
-
If VarStrength <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Strength =" + VarStrength
-
else
-
sqlst = sqlst & " AND Strength =" + VarStrength
-
End if
-
%>
-
-
<%
-
If VarGain_Loss <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Gain_Loss =" + VarDown
-
else
-
sqlst = sqlst & " AND Gain_Loss =" + VarGain_Loss
-
End if
-
%>
-
-
<%
-
If VarBench <> "" Then
-
if sqlst = "" Then
-
sqlst = sqlst & "Bench =" + VarBench
-
Else
-
sqlst = sqlst & "AND Bench =" + VarBench
-
End if
-
%>
-
-
<%
-
If VarPlay <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Play =" + VarDown
-
else
-
sqlst = sqlst & " AND Play =" + VarPlay
-
End if
-
%>
-
-
<%
-
If VarYardline <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Yardline =" + VarYardline
-
else
-
sqlst = sqlst & " AND Yardline =" + VarYardline
-
End if
-
%>
-
-
<%
-
If VarResult <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & "Result =" + VarResult
-
else
-
sqlst = sqlst & " AND Result =" + VarResult
-
End if
-
%>
-
-
<!--#include file="../Connections/e.asp" -->
-
-
<%
-
Response.Write(sqlst)
-
Response.Redirect(Results_Page)
-
%>
I've made some progress with the help of a friend. He says I needed to include the connection and then do the response.write sqlst.
How does this work?
My new code is below...
Patterson,
Looks like you are making progress - putting in the response.write line is sort of standard troubleshooting procedure - it just shows what you have done so far. However since you immediately follow it up with response.redirect you will never see what the sqlst is - as soon as you redirect you will lose everything you wrote.
Jared
BTW, please put your code in [ code] [ /code] tags (there is a button marked # provided when you post.
Ok, I'm making a little more progress now. I can get the database query to pull in all of my information from the variable constraints, but I can't get it to filter the recordset by these constraints. I'm also now getting an error message of
" Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Central vs LewisvilleWishbone2nd>6Right-1Right100AwayInt'.
/Eagle_Db2/Admin/process_db_query.asp, line 163 "
Any insight into how to get my string to filter these fields? - <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
-
<!--#include file="../Connections/e.asp" -->
-
<link href="../global_style.css" rel="stylesheet" type="text/css" />
-
-
<%
-
'Variable listed below here
-
'--------------------------------------------------------------------
-
%>
-
<%
-
-
'sets up variables in ASP from the submitted values of web page
-
Dim VarGame_Title, VarFormation, VarDown, VarDistance_Symbol, VarDistance, VarHash, VarStrength, VarGain_Loss, VarBench, VarResult, VarPlay, VarYardline, sqlst
-
-
VarGame_Title = request.form("Game_Title")
-
VarFormation = request.form("Formation")
-
VarDown = request.form("Down")
-
VarDistance_Symbol = request.form("Distance_Symbol")
-
VarDistance = request.form("Distance")
-
VarHash = request.form("Hash")
-
VarStrength = request.form("Strength")
-
VarGain_Loss = request.form("Gain_Loss")
-
VarBench = request.form("Bench")
-
VarResult = request.form("Result")
-
VarPlay = request.Form("Play")
-
VarYardline = request.Form("Yardline")
-
sqlst = ""
-
%>
-
-
<%
-
If VarGame_Title <> "" Then
-
if sqlst ="" then
-
sqlst = sqlst & VarGame_Title
-
End if
-
End if
-
%>
-
<%
-
If VarFormation <> "Any" Then
-
if sqlst <> "" then
-
sqlst = sqlst & VarFormation
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarDown <> "Any" Then
-
if sqlst <> "" then
-
sqlst = sqlst & VarDown
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarDistance_Symbol <> "any" Then
-
if sqlst <> "" then
-
sqlst = sqlst & VarDistance_Symbol & VarDistance
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarHash <> "Any" Then
-
if sqlst <> "" then
-
sqlst = sqlst & VarHash
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarYardline <> "Any" Then
-
if sqlst <> "" then
-
sqlst = sqlst & VarYardline
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarStrength <> "Any" Then
-
if sqlst <> "" then
-
sqlst = sqlst & VarStrength
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarPlay <> "" Then
-
if sqlst <> "" Then
-
sqlst = sqlst & VarPlay
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarGain_Loss <> "Any" Then
-
if sqlst <> "" Then
-
sqlst = sqlst & VarGain_Loss
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarBench <> "Any" Then
-
if sqlst <> "" Then
-
sqlst = sqlst & VarBench
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
<%
-
If VarResult <> "Any" Then
-
if sqlst <> "" Then
-
sqlst = sqlst & VarResult
-
End if
-
else
-
sqlst = sqlst
-
End if
-
%>
-
-
-
<p></p>
-
<p> </p>
-
<table width="698" border="0" align="center">
-
<tr>
-
<td bgcolor="#FFFFFF"><div align="center"><strong>You queried the database using the following contraints:</strong><br />
-
<font color="#0000FF">
-
<%Response.Write(sqlst)%>
-
</font></div></td>
-
</tr>
-
</table>
-
<center>
-
<p><br />
-
<br />
-
</p>
-
<p> </p>
-
-
-
<% if sqlst <> "" then
-
sqlst = " WHERE " + sqlst
-
session ("statement") = sqlst
-
else
-
sqlst = session("statement")
-
end if
-
%>
-
-
<%
-
Dim Play_Info
-
Dim Play_Info_cmd
-
Dim Play_Info_numRows
-
-
Set Play_Info_cmd = Server.CreateObject ("ADODB.Command")
-
Play_Info_cmd.ActiveConnection = MM_e_STRING
-
Play_Info_cmd.CommandText = "SELECT * FROM Play_Info" + sqlst
-
Play_Info_cmd.Prepared = true
-
-
Set Play_Info = Play_Info_cmd.Execute
-
Play_Info_numRows = 0
-
%>
-
<%
-
Dim Repeat1__numRows
-
Dim Repeat1__index
-
-
Repeat1__numRows = -1
-
Repeat1__index = 0
-
Play_Info_numRows = Play_Info_numRows + Repeat1__numRows
-
%>
-
<table border="1" cellpadding="3" cellspacing="3">
-
<tr>
-
<td>Play_Id</td>
-
<td>Formation</td>
-
<td>Down</td>
-
<td>Distance</td>
-
<td>Hash</td>
-
<td>Yardline</td>
-
<td>Strength</td>
-
<td>Play</td>
-
<td>Gain_Loss</td>
-
<td>Bench</td>
-
<td>Result</td>
-
<td>Comment</td>
-
<td>Game_Id</td>
-
<td>Game_Title</td>
-
</tr>
-
<% While ((Repeat1__numRows <> 0) AND (NOT Play_Info.EOF)) %>
-
<tr>
-
<td><%=(Play_Info.Fields.Item("Play_Id").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Formation").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Down").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Distance").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Hash").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Yardline").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Strength").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Play").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Gain_Loss").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Bench").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Result").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Comment").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Game_Id").Value)%></td>
-
<td><%=(Play_Info.Fields.Item("Game_Title").Value)%></td>
-
</tr>
-
<%
-
Repeat1__index=Repeat1__index+1
-
Repeat1__numRows=Repeat1__numRows-1
-
Play_Info.MoveNext()
-
Wend
-
%>
-
</table>
-
<p> </p>
-
-
-
-
-
<%
-
Play_Info.Close()
-
Set Play_Info = Nothing
-
%>
-
I appreciate any help you can offer.
Ok, I'm making a little more progress now. I can get the database query to pull in all of my information from the variable constraints, but I can't get it to filter the recordset by these constraints. I'm also now getting an error message of
"Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Central vs LewisvilleWishbone2nd>6Right-1Right100AwayInt'.
/Eagle_Db2/Admin/process_db_query.asp, line 163 "
Any insight into how to get my string to filter these fields?
I appreciate any help you can offer.
Easy peasy (as my kindergartner would say). Your SQL query has a syntax error. You need to do a really quick troubleshoot to figure it out, but once you see it it should be obvious. Here is what to do: - comment out the line that queries the database
- add a response.write line which prints out the query to the browser something like this:
- response.write "Query: " & sqlst & "<br>" & vbNewLine
- Look through what got printed out and check for VERY OBVIOUS mistakes, things like forgetting "AND" or spaces or commas
- If it doesn't seem obvious, post the entire query here and we can look at it.
Let me know how it goes.
Jared
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Eric Linders |
last post by:
Hello,
I have a Web form that is filled out on my company's web site. When
the submit button is pressed, the form data is posted to a PHP page
that (in the background) inserts their information...
|
by: Bob |
last post by:
Below is sample code that illustrates what I'm trying to do. For sake
of brevity I didn't include the properties of buildBtn that determine
what data to request.
The problem is I never see...
|
by: hb |
last post by:
Hi,
Would you please tell me how to detect if the client's browser is closed?
I need such event to trigger a database modification.
Thank you
hb
|
by: Tigger |
last post by:
Dear Experts,
I am working on ASP.NET. I have got a problem related to the usage of
Javascript in ASP.NET. Please help. The story is the following:
1) I am developing an ASP.NET application. I...
|
by: MikeM |
last post by:
We are getting a behavior on a Response.Redirect("SomeUrl", True) that I'm
hoping someone can explain. This all refers to the code snip at the end. By
the way, this is all VB ASP.NET v1.0 code.
...
|
by: James Radke |
last post by:
Hello,
I have a multithreaded windows NT service application (vb.net 2003) that I
am working on (my first one), which reads a message queue and creates
multiple threads to perform the processing...
|
by: pamelafluente |
last post by:
I am beginning aspNet, I know well win apps.
Need a simple and schematic code example to start work.
This is what I need to accomplish:
----------------------
Given button and a TextBox on a...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: Xah Lee |
last post by:
Text Processing with Emacs Lisp
Xah Lee, 2007-10-29
This page gives a outline of how to use emacs lisp to do text
processing, using a specific real-world problem as example. If you
don't know...
|
by: Nadeem Ashraf |
last post by:
Hi,
We are developing a web based application "UltraLearn.com" with a mix of
junior/senior Microsoft technologies. That includes Microsoft Silverlight,
ASP.Net Ajax and WCF/WF. Recently, we have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |