Problem with an .asp page displaying data based on a form field value.

Problem with an .asp page displaying data based on a form field value.

am 14.02.2007 20:18:16 von bravesplace

I'm hoping someone can help me with a small issue.

I have an asp page that displays informaton from an Access database.
I want to create a form that allows users to display only data that
matches their search criteria.

I have made many forms like this in Front Page with the Database
results wizard, but I want to manually code it.

Here is the code I use to display the data from a database.

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=\\****\****
\DatabaseName.mdb;"
mySQL="SELECT * FROM DatabaseTableName WHERE (TableFieldName =
'FieldValue') ORDER BY TableFieldName ASC"
Set RS = Conn.Execute(mySQL)
If RS.EOF and RS.BOF Then
Response.Write("

No records
returned.

")

Else

Response.Write ""
Response.Write ""
Response.Write ""

Do While Not RS.EOF

Response.Write ""
Response.Write ""
Response.Write ""

RS.MoveNext
Loop
End If

Response.Write "
Table Field Name
"&RS("FieldValue")&"
"

RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
%>

What I want to do is add a form like the one below that user can use
to determine the "field value" that is displayed.

NAME="FormField" VALUE="<%=Request("FormFieldValue")%>"
size="24"> 



So if they type in "Smith" they get all entries that have a field
value of Smith

I'm not sure how to write the query so it looks at the form for the
value it uses to display information.

Any code examples would help me a great deal as I seem to be close,
but I cannot "connect" to two elements.

Thanks for taking the time to read all of this, and for any assiatance
you can offer.

Re: Problem with an .asp page displaying data based on a form field value.

am 16.02.2007 07:33:39 von David Kirkby

I think you want something like this:

mySQL="SELECT * FROM DatabaseTableName WHERE (TableFieldName='" &
Request.Form("FieldValue") & "') ORDER BY TableFieldName ASC"

It's a single quote followed by doublequotes after TableFieldName=, and
doublequotes followed by a single quote before the ORDER BY


"Brave" wrote in message
news:1171480696.112939.203000@a75g2000cwd.googlegroups.com.. .
> I'm hoping someone can help me with a small issue.
>
> I have an asp page that displays informaton from an Access database.
> I want to create a form that allows users to display only data that
> matches their search criteria.
>
> I have made many forms like this in Front Page with the Database
> results wizard, but I want to manually code it.
>
> Here is the code I use to display the data from a database.
>
> <%
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=\\****\****
> \DatabaseName.mdb;"
> mySQL="SELECT * FROM DatabaseTableName WHERE (TableFieldName =
> 'FieldValue') ORDER BY TableFieldName ASC"
> Set RS = Conn.Execute(mySQL)
> If RS.EOF and RS.BOF Then
> Response.Write("

No records
> returned.

")
>
> Else
>
> Response.Write ""
> Response.Write ""
> Response.Write ""
>
> Do While Not RS.EOF
>
> Response.Write ""
> Response.Write ""
> Response.Write ""
>
> RS.MoveNext
> Loop
> End If
>
> Response.Write "
Table Field Name
"&RS("FieldValue")&"
"
>
> RS.Close
> Conn.Close
> Set RS = Nothing
> Set Conn = Nothing
> %>
>
> What I want to do is add a form like the one below that user can use
> to determine the "field value" that is displayed.
>
>

> NAME="FormField" VALUE="<%=Request("FormFieldValue")%>"
> size="24"> 


>
> So if they type in "Smith" they get all entries that have a field
> value of Smith
>
> I'm not sure how to write the query so it looks at the form for the
> value it uses to display information.
>
> Any code examples would help me a great deal as I seem to be close,
> but I cannot "connect" to two elements.
>
> Thanks for taking the time to read all of this, and for any assiatance
> you can offer.
>

Re: Problem with an .asp page displaying data based on a form field value.

am 16.02.2007 14:21:34 von bravesplace

On Feb 16, 1:33 am, "Patrick" wrote:
> I think you want something like this:
>
> mySQL="SELECT * FROM DatabaseTableName WHERE (TableFieldName='" &
> Request.Form("FieldValue") & "') ORDER BY TableFieldName ASC"
>
> It's a single quote followed by doublequotes after TableFieldName=, and
> doublequotes followed by a single quote before the ORDER BY
>
> "Brave" wrote in message
>
> news:1171480696.112939.203000@a75g2000cwd.googlegroups.com.. .
>
>
>
> > I'm hoping someone can help me with a small issue.
>
> > I have an asp page that displays informaton from an Access database.
> > I want to create a form that allows users to display only data that
> > matches their search criteria.
>
> > I have made many forms like this in Front Page with the Database
> > results wizard, but I want to manually code it.
>
> > Here is the code I use to display the data from a database.
>
> > <%
> > Set Conn = Server.CreateObject("ADODB.Connection")
> > Conn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=\\****\****
> > \DatabaseName.mdb;"
> > mySQL="SELECT * FROM DatabaseTableName WHERE (TableFieldName =
> > 'FieldValue') ORDER BY TableFieldName ASC"
> > Set RS = Conn.Execute(mySQL)
> > If RS.EOF and RS.BOF Then
> > Response.Write("

No records
> > returned.

")
>
> > Else
>
> > Response.Write ""
> > Response.Write ""
> > Response.Write ""
>
> > Do While Not RS.EOF
>
> > Response.Write ""
> > Response.Write ""
> > Response.Write ""
>
> > RS.MoveNext
> > Loop
> > End If
>
> > Response.Write "
Table Field Name
"&RS("FieldValue")&"
"
>
> > RS.Close
> > Conn.Close
> > Set RS = Nothing
> > Set Conn = Nothing
> > %>
>
> > What I want to do is add a form like the one below that user can use
> > to determine the "field value" that is displayed.
>
> >

> > NAME="FormField" VALUE="<%=Request("FormFieldValue")%>"
> > size="24"> 


>
> > So if they type in "Smith" they get all entries that have a field
> > value of Smith
>
> > I'm not sure how to write the query so it looks at the form for the
> > value it uses to display information.
>
> > Any code examples would help me a great deal as I seem to be close,
> > but I cannot "connect" to two elements.
>
> > Thanks for taking the time to read all of this, and for any assiatance
> > you can offer.- Hide quoted text -
>
> - Show quoted text -

Thanks so much. I will give it a try.