Article View: comp.databases.ms-access
Article #253Problems using ASP with MS Access
From: Martin Madsen
Date: Sun, 30 Nov 1997 00:00
Date: Sun, 30 Nov 1997 00:00
94 lines
3756 bytes
3756 bytes
Hi, databasegurus
My problem is as follows:
I�ve made an MS Access Databse and would now like to search that online
using asp. In that process i have made my HTML form with the fields that i
need to restrict my return-records. I�ve also made an asp files to find
those records matching my criteria set on my HTML form.
First please take a look at some of my asp-file:
-------------------------------------------------------------------------
<% strNavn = cStr(request.form("navn"))
strAdresse = cStr(request.form("adresse"))
strPostnummer = cStr(request.form("postnummer"))
strBy = cStr(request.form("by"))
strTelefonnummer = cStr(request.form("telefonnummer"))
strFaxnummer = cStr(request.form("faxnummer"))
strEmail = cStr(request.form("email"))
strWeb = cStr(request.form("web"))
strKommune = cStr(request.form("kommune"))
strAmt = cStr(request.form("amt"))
strLand = cStr(request.form("land"))
set ObjConn=Server.CreateObject("ADODB.Connection")
ObjConn.open "Opencities"
SQL = "SELECT * FROM Samarbejdspartner WHERE Samnavn LIKE '%" & strNavn &
"%' AND Postnummer LIKE '%" & strPostnummer & "%' AND Adresse LIKE '%" &
strAdresse & "%' AND By LIKE '%" & strBy & "%' AND Tlf LIKE '%" &
strTelefonnummer & "%' AND Fax LIKE '%" & strFaxnummer & "%' AND E-Mail
LIKE '%" & strEmail & "%' AND WEB LIKE '%" & strWeb & "%' AND Kommune LIKE
'%" & strKommune & "%' AND Amt LIKE '%" & strAmt & "%' AND Land LIKE '%" &
strLand & "%' ORDER BY Samnavn, By"
----------------------------------------------------------------------------
----
My HTML form has 3 fields: "navn", "postnummer", "by"
Here is an example:
I would like to find all records where "Postnummer" (Zipcode in danish) =
7100. I type 7100 in the "Postnummer" field on my HTML form and press
submit and the asp file returns these 2 records:
Navn: Alan Smith
Postnummer: 7100
By: Vejle
Navn: Peter Hansen
Postnummer: 7100
By: Vejle
That should be ok, one migth think ! The problem is that my database has 3
records with 7100 in Postnummer. Here are my 3 records as they are in my
Access database.
Navn: Alan Smith
Postnummer: 7100
By: Vejle
Navn: Peter Hansen
Postnummer: 7100
By: Vejle
Navn: Martin Oliver Madsen
Postnummer: 7100
By:
What you migth see is that the last record has no data in the "By" (City in
danish). I think is is obvious that my asp file would return 2 records if i
searched for "By" = Vejle. Only 2 records has Vejle in there By field.
What i think is wrong is, that if you do not type anything into all the
fields an the HTML form, the blank fields on the HTML form passes some kind
of value to the ASP file. How do i check for that ? How do i state in a ASP
file that fields passed from a HTML form that has no value should be
overlooked.
I hope that you can understand my problem, and that you know how to solve
it or give some hints.
I�ve asked this question on other forums and mailinglists without luck.
This is my last chance :)
Thanks in advance for any advice....
Martin Oliver Madsen
Denmark
Technical Details
Message-ID:
<01bcfdd4$a0750950$40c0e482@ns>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: ff0ac,3256b8a733bfbea9,start X-Google-Attributes: gidff0ac,public X-Google-Thread: 10779a,3256b8a733bfbea9,start X-Google-Attributes: gid10779a,public X-Google-Thread: fa6f6,3256b8a733bfbea9,start X-Google-Attributes: gidfa6f6,public From: "Martin Madsen" <mm@frawagn.dk> Subject: Problems using ASP with MS Access Date: 1997/11/30 Message-ID: <01bcfdd4$a0750950$40c0e482@ns> X-Deja-AN: 293996136 Organization: News Server at UNI-C, Danish Computing Centre for Research and Education. Newsgroups: comp.databases.ms-access,dk.edb.programmering,microsoft.public.access