Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search and display records. 2

Status
Not open for further replies.

alan28

Technical User
Jul 31, 2002
60
GB
I have tried working though the onboard tutorials for this but they are quite confusing. I want to display records from the database on one single one-search parameter. I have built the search page that I think is ok, But the results page, what do I have to do to display the records? Do I just drag out the data from the record set?

I am using ultradev 4.
 
[tt]

Create a table with the field you want to display
like:
Name: rs("namefield")
Address: rs("addressfield")
City: rs("cityfield")
State: etc...
Zip: etc...
Hphone: etc...
Cell: etc...
WPhone:
etc...

I would suggest creating a table to better format the look and yes, just drag your fields.
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
I am getting this error message, anyone any ideas what I am doing wrong?

HTTP Error 405
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.
 
[tt]

Post the code that's giving you this error to better troubleshoot it.
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
This is the code from the results page:

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/speed.asp&quot; -->
<%
Dim Speed__MMColParam
Speed__MMColParam = &quot;1&quot;
if (Request.Form(&quot;Speed&quot;) <> &quot;&quot;) then Speed__MMColParam = Request.Form(&quot;Speed&quot;)
%>
<%
set Speed = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Speed.ActiveConnection = MM_speed_STRING
Speed.Source = &quot;SELECT * FROM speed WHERE Name = '&quot; + Replace(Speed__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;' ORDER BY Name ASC&quot;
Speed.CursorType = 0
Speed.CursorLocation = 2
Speed.LockType = 3
Speed.Open()
Speed_numRows = 0
%>
 
[tt]

What the value of (Speed__MMColParam ??

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/speed.asp&quot; -->
<%
Dim Speed__MMColParam
Speed__MMColParam = &quot;1&quot;
if (Request.Form(&quot;Speed&quot;) <> &quot;&quot;) then Speed__MMColParam = Request.Form(&quot;Speed&quot;)
%>
<%
set Speed = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Speed.ActiveConnection = MM_speed_STRING
Speed.Source = &quot;SELECT * FROM speed WHERE Name = '&quot; + Replace(Speed__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;' ORDER BY Name ASC&quot;
Speed.CursorType = 0
Speed.CursorLocation = 2
Speed.LockType = 3
Speed.Open()
Speed_numRows = 0
%>
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
I can not work that out. I deleted the record set and started again. Still will not work. I have tested the SQL statement and that works. I am know getting this error message.

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.

/intranet1/TMP338gr8q3ju.asp, line 69
 
I deleted the two pages and started again, I am getting the same error message.
How are you supposed to delete a record set?

 
I deleted the record set by using the (-) sign to delete the record set but still getting the same error message. Do I need to set a new connection?
 
[tt]

Ok alan28, In order for your search to work properly, you have to tell the recordset in the results/display page to select everything from a recordset where the values from the field being submitted are the same.

On my sample below, I'm pulling everything where the login field is the same.

image1.bmp


Then I create a table and drag my recordset fields to where I need them to display.


image2.bmp


Then click on your table and click on &quot;server behaviors&quot; and select &quot;repeat region&quot; to make the records loop and display all records found.

image3.bmp


Let me know if you have anymore questions.


I will delete these images tomorrow.
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
Thanks for the help Tony, What you detailed in your post is what I have been doing. I keep getting the error message that I posted earlier.

One thing that is happing is when I drag out from the record set, some of them appear as an asp sign and some arecolored in blue, like yours.

I only what to display one record so I think I don't need to do a repeat region?

I have tried deleting the two pages and starting again but I still get that error message. I don't understand why this is happening considering I have deleted the pages.
 
[tt]
I think the problem lies in your loop, you will have to loop thru the recordset because the variable you're searching for will most likely not be the first records all the time.

Sample from aspfaq:

<%
set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.open <connection string>
set rs = conn.execute(&quot;SELECT lastname FROM table WHERE firstname LIKE '%frank%'&quot;)
if not rs.eof then
do while not rs.eof
response.write rs(&quot;lastname&quot;) & &quot;<br>&quot;
rs.movenext
loop
else
response.write &quot;No matches.&quot;
end if

%>
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
Tony's all over the answer here

but I think we're missing an element
we need the text field names from the input form.

Also - I see the TMP.

Is this saved and uploaded to the net or are you just previewing in browser? &quot;Never underestimate the power of determination&quot;

Stuart
 
[tt]
You're right schase, duh on my part...
* * * * * * * * * * *
<%=Tony%>
cold.gif

 
I am not quite sure what you mean Schase. There has to be one small thing that I am overlooking here. The onboard tutorial obviously works and as far as I am concerned I am following it to the letter.

Do you mean the text field names on the search page? I have not given them a name, could this be the problem? The onboard tutorial does not mention you have to set them up though.

 
yup,

the second page pulls info from the first. &quot;Never underestimate the power of determination&quot;

Stuart
 
Yes it was not naming the text field. I thought it would be something simple that I was missing.

Another problem though - when I search for something that is not in the database I get the same error message as before.
 
This is where Tony's code comes into play.

Put this where you want the fields to display

if not rs.eof then
do while not rs.eof
response.write rs(&quot;lastname&quot;) & &quot;<br>&quot;
rs.movenext
loop
else
response.write &quot;No matches.&quot;
end if

you'll have to modify that to fit your page - if your unsure about this, than copy and paste the table your putting data out to. &quot;Never underestimate the power of determination&quot;

Stuart
 
Another point,

many tutorials kinda neglect to mention this to any detail.

But at some point your going to come accross a 80040e14 error - Syntax error in INSERT INTO statement.

Reserved name fields - in fact your using one of them now.

heres a link for more info on Macromedia

Now you could spend lots of time trying to pick and place what words you can use - or get into a habit early and start a naming convention.

Here is what I do.

Any database's I start with db like dbChase
any database tables I start with tbl like tblUsers
any database table fields I start with fld like fldFirstName
any database queries I start with qry like qryUsers

In any form fields I start with txt like txtFirstName

any Sessions I start with sv like svFirstName
any Dim's I start with str like strFirstName

it takes a little to get used too - but once you do - its much much easier. look at below code I will write, see if you can spot where they are residing - and what they are.

<% Dim strFirstName
strFirstName = request.form(&quot;txtFirstName&quot;)


rsTemp = &quot;SELECT * from tblUsers where fldUserName='&quot; & strFirstName & &quot; ORDER BY Session(&quot;svLastName&quot;) & &quot; DESC&quot;

%>

not a complete recordset, but see where everything is?

I'm getting strFirstName by populating it from a form text field named txtFirstName,
my SQL Statement says to take every record from table Users where the username = the first name populated earlier into strFirstName - then order by last name.

Not only is it much easier to keep track of - you never run into reserved names again. &quot;Never underestimate the power of determination&quot;

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top