|
| |
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
Is it spaces in Sql that are blocking me? - 12/28/2006 9:52:58
Hello all! Once again, i'm down to one small thing that is just killing me. I have select menus populating from an sql database and everything is working fine except for 1 name, the only thing different is that it has a space "Arctic Cat" I had 2 names, "Arctic Cat" and "Gas-Gas" in the database that were messing my code up so I made an if else statement and set a variable: <%If request.querystring("Co_Code")="Arctic Cat" then%>
<%Namefix="Arctic_Cat"%>
<% Else %>
<% If request.querystring("Co_Code")="Gas-Gas" then%>
<%Namefix="Gas_Gas">
<% Else %>
<%Co_Code=request.querystring("Co_Code")%>
<% End If %> Then I made querys on the server called Yamaha_List, Honda_List, Gas_Gas_List, Arctic_Cat_List and checked them, they ran fine. But when I try to pick "Arctic Cat" from the list it just shows up blank? I have a test page up: http://velocityincadmin.com/allballs/test2.asp here's the code calling the list: <%
if Namefix<>"" then
sql="SELECT DISTINCT Model_No FROM "&Namefix&"_list WHERE veh_type='"& veh_type & "' ORDER by Model_No"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn%>
<form method="get">
Choose Model NF <select name="Model_No">
<% do until rs.EOF
response.write("<option")
if rs.fields("Model_No")=Model_No then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("Model_No"))
rs.MoveNext
loop
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Set Vehicle">
</form> P.S. the Veh_Type is either ATV, OR, UTV, ST I made a page and just hard coded Arctic_Cat_List and it works? here is the code for that page: <%
Dim veh_type
veh_type="ATV"
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "PROVIDER=SQLOLEDB;SERVER=67.59.176.188;UID=uname;" & _
"PWD=password;DATABASE=theDatabase"
conn.Open
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT DISTINCT Model_No FROM Arctic_Cat_List WHERE veh_type='"& veh_type & "' ORDER by Model_No"
rs.Open sql,conn
%>
<form method="post">
Choose Customer <select name="Model_No">
<% do until rs.EOF
response.write("<option")
if rs.fields("Model_No")=Co_Code then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("Model_No"))
rs.MoveNext
loop
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Show Models">
</form> here's that page: http://velocityincadmin.com/allballs/test.asp As always thanks a ton for any help
|
|
|
|
rdouglass
Posts: 9227 From: Biddeford, ME USA Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 12/28/2006 10:02:09
quote:
here's that page: http://velocityincadmin.com/allballs/test.asp The dropdown on that page needs closing tags </option> on each item. You need to add the apropriate response.write to your loop. The test2 page is the same. It (the dropdown) doesn't know when the value stops or starts. Add that tag to both menus and see if that helps.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
rdouglass
Posts: 9227 From: Biddeford, ME USA Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 12/28/2006 10:24:19
quote:
still that Arctic Cat thing is messing with me. Do you have a page with the dropdowns correct?? Maybe I can take a quick peek again?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 12/28/2006 10:35:02
P.S. This was my work around to the Java script. So i'm sure it's got it's flaws. I thought it might run a bit faster being that it's calling from stored database views on the server.
|
|
|
|
BeTheBall
Posts: 6359 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 12/28/2006 10:40:44
Try this: <% do until rs.EOF response.write("<option value='"& rs.fields("Model_No") &"'") if rs.fields("Model_No")=Co_Code then response.write(" selected") end if response.write(">") response.write(rs.fields("Model_No")) response.write("</option>") rs.MoveNext I have seen users miss putting their option values in quotes and then have problems when the value has a space in it. I am guessing the same holds true when you try to use this syntax: <option>option value</option> instead of: <option value="option value">option value</option> You would need to add a value attribute to any and all dropdowns.
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 12/28/2006 11:07:24
Bummer, I was all excited thinking that might have been it... to no avail. Nice though, I overlooked that. I did run into that problem before and setting the value did help. I'll keep pluggin away. :) Thanks though!
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 12/28/2006 13:40:02
Thanks Spooky!...I made a new page...Test3.asp and pasted that code, it's giving me the error I had before I messed with the code. It's from Arctic Cat having a space. Microsoft OLE DB Provider for SQL Server error '80040e37' Invalid object name 'Arctic'. /allballs/test3.asp, line 106 http://velocityincadmin.com/allballs/test3.asp The database it needs to call is Arctic Cat_List I am probalby missing one of those quotes? Not sure where though?
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 1/2/2007 13:30:05
Sooooo close... I have a feeling someone will get this... i've tried everything though? It's giving me this error: ADODB.Recordset error '800a0bb9' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another. /allballs/test3.asp, line 139 Here is the code at the top of my page setting the variables: <%If request.form("Co_Code")="Arctic Cat" then%>
<%Namefix="ArcticCat"
Nameoption="Arctic Cat"%>
<% Else %>
<% If request.form("Co_Code")="Gas-Gas" then%>
<%Namefix="Gas_Gas"
Nameoption="Gas-Gas"%>
<% Else %>
<%Co_Code=request.form("Co_Code")%>
<% End If %>
<%
veh_type=request.form("veh_type")
veh_year=request.form("veh_year")
Model_No=request.form("Model_No") and here is line the code from line 135 to line 140: <%
if Namefix<>"" then
sql="SELECT DISTINCT Model_No FROM " & Namefix & "_list WHERE veh_type='"& veh_type & "' ORDER by Model_No"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%> The name of the actual database view is ArcticCat_list (I got rid of the space incase that was the issue.) Any ideas for that error? What's really strange is the Gas-Gas one works perfect?
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 1/2/2007 13:53:07
ahhhh... it's showing that veh_type isn't coming in? SELECT DISTINCT Model_No FROM ArcticCat_list WHERE veh_type='' ORDER by Model_No still confused on why it wouldn't bring that over when all the others do? believe it or not, I didn't even thing to do a response.write to see what was actually going on! So I thank you there...
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 1/3/2007 16:03:21
I tried a small test being that the only thing different is that there is a space in the feild value "Arctic Cat". So I went into the database and changed about 6 records to "ArcticCat" and when I chose one from the list, it brought over the veh_type? but it won't when you pick "Arctic Cat"? Does anyone know what that would be called? Namespaces? Field value spaces? I can't find anything online about it? Thanks in advance! Scott
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 1/3/2007 16:30:07
Sure! Thanks for checking it out here is the whole page: <%@ language="vbscript"%>
<html>
<body>
<%If request.form("Co_Code")="Arctic Cat" then%>
<%Namefix="ArcticCat"
Nameoption="Arctic Cat"
%>
<% Else %>
<% If request.form("Co_Code")="Gas-Gas" then%>
<%Namefix="GasGas"
Nameoption="Gas-Gas"%>
<% Else %>
<%Co_Code=request.form("Co_Code")%>
<% End If %>
<%
veh_type=request.form("veh_type")
veh_year=request.form("veh_year")
Model_No=request.form("Model_No")
response.write(veh_type)
response.write(veh_year)%>
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "PROVIDER=SQLOLEDB;SERVER=67.59.176.188;UID=------;" & _
"PWD=-------;DATABASE=------"
conn.Open
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT DISTINCT veh_type FROM Vehicle ORDER BY veh_type"
rs.Open sql,conn
%>
<form method="post">
Choose Vehicle Type <select name="veh_type">
<% do until rs.EOF
response.write("<option value="""&rs.fields("veh_type")&"""")
if rs.fields("veh_type")=veh_type then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("veh_type"))
rs.MoveNext
loop
response.write("</option>")
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Show Models">
</form>
<% End If %>
<%
if veh_type<>"" then
sql="SELECT DISTINCT veh_year FROM " & veh_type & "_list ORDER by veh_year DESC"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>
<form method="post">
Choose Year <select name="veh_year">
<% do until rs.EOF
response.write("<option """&rs.fields("veh_year")&"""")
if rs.fields("veh_year")=veh_year then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("veh_year"))
rs.MoveNext
loop
response.write("</option>")
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Show Makes">
<input type="hidden" name="veh_type" value="<%response.write(veh_type)%>">
</form>
<% End If %>
<%
if veh_year<>"" then
sql="SELECT DISTINCT Co_Code FROM " & veh_type & "_list WHERE veh_year='"& veh_year & "' ORDER by Co_Code"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>
<form method="post">
Choose Make <select name="Co_Code">
<% do until rs.EOF
response.write("<option """&rs.fields("Co_Code")&"""")
if rs.fields("Co_Code")=Co_Code or rs.fields("Co_Code")=Nameoption then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("Co_Code"))
rs.MoveNext
loop
rs.Close
set rs=Nothing %>
</select>
<input type="text" name="veh_type" value="<%response.write(veh_type)%>">
<input type="text" name="veh_year" value="<%response.write(veh_year)%>">
<input type="submit" value="Show Models">
</form>
<% End If %>
<%
if Co_Code<>"" then
sql="SELECT DISTINCT Model_No FROM " & Co_Code & "_list WHERE veh_type='"& veh_type & "' ORDER by Model_No"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>
<form method="post">
Choose Model <select name="Model_No">
<% do until rs.EOF
response.write("<option """&rs.fields("Model_No")&"""")
if rs.fields("Model_No")=Model_No then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("Model_No"))
rs.MoveNext
loop
response.write("</option>")
rs.Close
set rs=Nothing %>
</select>
<input type="text" name="veh_type" value="<%response.write(veh_type)%>">
<input type="text" name="veh_year" value="<%response.write(veh_year)%>">
<input type="text" name="Co_Code" value="<%response.write(Co_code)%>">
<input type="submit" value="Set Vehicle">
</form>
<% End If %>
<%
if Namefix<>"" then
sql="SELECT DISTINCT Model_No FROM " & Namefix & "_list WHERE veh_type='"& veh_type & "' ORDER by Model_No"%>
<%
response.write sql
response.end
set rs=Server.CreateObject("ADODB.Recordset")
%>
Veh_Type: <%response.write(veh_type)%><br>
Veh_Year: <%response.write(veh_year)%><br>
Co_Code: <%response.write(Co_Code)%><br>
Vehicle Make(Namefix): <%response.write(Namefix)%><br>
Vehicle Model(Model_No): <%response.write(Model_No)%><br>
</table>
<% End If %>
</body>
</html>
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 1/3/2007 18:14:27
Sorry Spooky... Did I give you the right link? It should be: http://velocityincadmin.com/allballs/test3.asp I fixed the table name to GasGas (when I was troubleshooting I got rid of the underscores) I changed the Namefix variable too. So it sets it to GasGas. You'll see text on the page as you select menus, that's just so I know it's carrying the variable over. :)
|
|
|
|
Twopigs
Posts: 147 Joined: 8/22/2002 Status: offline
|
RE: Is it spaces in Sql that are blocking me? - 1/3/2007 18:53:35
Yea, I took out the space on some of them, so when the select distinct kicks in, it grabs them both.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|