hi
i am designing a database using Ms Access and ASP. i have 3 tables in access namely 'PERSONAL', other as 'POLICY' and 3rd one is named as 'STAFF'. in the contact table i have ID, Name, Children as fields. Also in policy table the firlds are:- ID, date_of_policy, no_policy, amount_paid, amount_balance and similarly the 3rd ie., staff has few fields. all three are linked my a common field which is ID
all i want is when the user searches for a perticular name (from frontend) it should search through table- 'PERSONAL' (fields- Name and Children). once it get the perticular name with the help of the ID it should retrive the datafrom both 'POLICY' and 'STAFF' of that perticular Name.
i do know how to search and retrive data from the same table but got a bit confused on how to retrive data from different tables using the 'PERSONAL' table just for reference and linking to the other 2 tables
plz help
thanking
neha
23 3418 jhardman 3,406
Recognized Expert Specialist
Neha,
You don't need to open the tables separately, try: -
query = "SELECT * FROM PERSONAL, POLICY, STAFF, WHERE PERSONAL.ID=POLICY.ID AND POLICY.ID=STAF.ID AND Name = 'Joe'"
-
This pulls up all of the data for the same ID as if it was in a single table.
Let me know if this helps.
Jared
thanks Jared
this helped me but my problem is that i cannt specify name = Joe.....
it depends on the user which name they select on the front end [ASP] the information of that perticular name (typed by user) should be displayed (& there can be thousands of name).
plz help
neha
jhardman 3,406
Recognized Expert Specialist
Neha,
Right, I just meant for this as an example. The query string is just a string variable arranged in such a way that a db driver can understand it. You assemble the string the same way you assemble any string: -
query = "SELECT * FROM PERSONAL, POLICY, STAFF, WHERE PERSONAL.ID=POLICY.ID AND POLICY.ID=STAF.ID AND Name = '"
-
query = query & request("nameOfLogin") & "'"
-
nameOFLogin is whatever you called the login name on the form:
[html]<input type="text" name="nameOfLog in">
[/html]
Please let me know if this makes sense.
Jared
Neha,
Right, I just meant for this as an example. The query string is just a string variable arranged in such a way that a db driver can understand it. You assemble the string the same way you assemble any string: -
query = "SELECT * FROM PERSONAL, POLICY, STAFF, WHERE PERSONAL.ID=POLICY.ID AND POLICY.ID=STAF.ID AND Name = '"
-
query = query & request("nameOfLogin") & "'"
-
nameOFLogin is whatever you called the login name on the form:
[html]<input type="text" name="nameOfLog in">
[/html]
Please let me know if this makes sense.
Jared
hi Jared i have tried your query with changes in name but there is some error comming which i am not able to makeout
the following is the sql i am using:- - strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID And Drug_Name.D_Name = '"
-
strSQL = strSQL & request("search") &"' "
when i use this code the result is not shown at all
so i tried doing like this:- - strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID And Drug_Name.D_Name = "& request("search") &" "
and the error that is showing is
Expected end of statement
/MyWeb/mylogin/testquery.asp, line 24, column 112
strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ ID = Chemistry.Drug_ ID And
Drug_Name.D_Nam e = "strSearch" "
-----------------------------------------------------------------------------------------
-------------------------------------------------------------------
---------------------^
i dont understand what is wrong is these codes
neha
jhardman 3,406
Recognized Expert Specialist
hi Jared i have tried your query with changes in name but there is some error comming which i am not able to makeout
the following is the sql i am using:- - strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID And Drug_Name.D_Name = '"
-
strSQL = strSQL & request("search") &"' "
when i use this code the result is not shown at all
so i tried doing like this:- - strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID And Drug_Name.D_Name = "& request("search") &" "
and the error that is showing is
Expected end of statement
/MyWeb/mylogin/testquery.asp, line 24, column 112
strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ ID = Chemistry.Drug_ ID And
Drug_Name.D_Nam e = "strSearch" "
-----------------------------------------------------------------------------------------
-------------------------------------------------------------------
---------------------^
i dont understand what is wrong is these codes
neha
The text field should definitely be in single quotes so that the query looks like this:
Possibly this isn't bringing up any hits because there are no exact matches, I think this might be case sensitive (an exact match is necessary). Instead you could try: -
AND D_Name LIKE %aspirin%
-
This should not be case sensitive, and doesn't produce only exact matches.
After I write the query, to make sure it looks good, I often write the query to an HTML comment: -
response.write "<!-- strSQL: " & strSQL & " -->" & vbNewLine
-
This lets me verify that the database is seeing what it should
Let me know if this helps.
Jared
Jared
thanks for the help
i am very much sure that this is not case sensitive... to retrive data from the same table i have used almost the same coding and it worked perfectly alright....
this is the whole code i am using - <HTML>
-
<BODY>
-
<%
-
Actionvar=Request.QueryString("actionvar")
-
strURL = Request.ServerVariables("URL")
-
strSearch = Request.querystring("search")
-
%>
-
<p>Search our sample db by first or last name. (% returns all)</p>
-
<form action="<%= strURL %>" method="post">
-
<input type = "text" name="search" size = "30" value="<%= strSearch %>" />
-
<input type="submit" />
-
</form>
-
<%
-
If strSearch <> "" Then
-
Set conn = server.createobject("adodb.connection")
-
DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
-
DSNtemp=dsntemp & "DBQ=" & server.mappath("Databases/nprcDrugsDB.mdb")
-
conn.Open DSNtemp
-
-
strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID And Drug_Name.D_Name = '"
-
strSQL = strSQL & request.form("search") &"' "
-
-
Set rstSearch = conn.execute(strSQL)
-
%>
-
<table border="1">
-
<tr>
-
<th>Name</th>
-
<th>Salts</th>
-
</tr>
-
<%
-
Do While Not rstSearch.EOF
-
%>
-
<tr>
-
<td><%= rstSearch.Fields("Drug_Name.D_Name").Value %></td>
-
<td><%= rstSearch.Fields("Chemistry.Salts").Value %></td>
-
</tr>
-
<%
-
rstSearch.MoveNext
-
-
Loop
-
%>
-
</table>
-
<%
-
rstSearch.Close
-
conn.Close
-
Set conn = nothing
-
Set strSQL = nothing
-
End If
-
%>
-
</BODY>
-
</HTML>
i guess i am not declaring some thing .........becaus e when i execute this code only the HTML codes work and not the ASP Codes...... do i have to declare strSQL else where also or some thing is wrong for retrival ASP code of mine
neha
is my ASP code to retrive data after the SQL query is not correct????? how do i retrive my queried data in a tabular form then?????
neha
jhardman 3,406
Recognized Expert Specialist
Neha,
It definitely looks OK to me. I don't see any problems. Try using "LIKE" instead of "=" though and put your drug name in "%" instead of "'"
Jared
hi Jared,
well i have changed my SQL codes as u told -
strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID AND Drug_Name.D_name LIKE '%" & strSearch & "%' "
but the result is same only empty tables comes and no information.... .what im thinking is that ASP codes is not working over here or SQL query is not taken in to account........ well im sure of connectivity is correct as its working fine when only one table is involved....... .
what do i do i need to complete this by this weekend and its giving me so much problem...
any waz thank so much for the help u provided
thanks again plz let me know if you get an idea of whats wrong over here.......
thanks again
neha
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: D Witherspoon |
last post by:
I am developing a Windows Forms application in VB.NET that will use .NET
remoting to access the data tier classes.
A very simple way I have come up with is by creating typed (.xsd) datasets.
For example dsParts.xsd and including that in the data tier. I then will
create a class that looks like this
Public Class CPart
Inherits dsParts
|
by: Neil Ginsberg |
last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC
linked tables. I recently created a new set of tables for the app, and users
are complaining that unsaved data is being lost when they move to a new
record. This seems to be the case when there are multiple users. When there
is a single user using it, we don't seem to have that problem.
It seems that we had this problem when we first converted from an MDB back
end...
|
by: Sami |
last post by:
Please bear with me, and if you answer this question, please do it
step by step. I am new at Access, not at all sophisticated. I am
using Office XP. This will need to be read in Access for Office 2000.
I am creating a database to track student athletes. I have created
the following tables. The table title is to the far left, with fields
under each. The common field will be the StudentID field, which is
their student number assigned...
|
by: Nico |
last post by:
My database have 20 tables and many users. I wish to store encrypted
data in 3 tables and have only 3 users have access to them, walking
into tables or using forms.
Can someone point me a direct help or something to read?
Tnx
Nico
|
by: Terry |
last post by:
Any .dll or COM+ for .Net can help me retrive data from a Access file?
The table contain several columns and the last one is a container
which I store Article; because each article is a little bit huge, so
when I store it, it ask me if I want to pack it (the article) into a
object then I click 'Yes'. But now I need to retrive data from the
file and show it by datagrid, and now I don't know what kind of data
type it is (when I click it, it...
| |
by: Anil Gupte |
last post by:
After reading a tutorial and fiddling, I finally got this to work. I can
now put two tables created with a DataTable class into a DataRelation.
Phew! And it works!
Dim tblSliceInfo As New DataTable("SliceInfo")
Dim tblSliceRatings As New DataTable("SliceRatings")
'.... All the adding datacolumns, datarows, etc. goes here..
DatasetInit.Tables.Add(tblSliceInfo)
|
by: amritranjan |
last post by:
How to retrive image file from MS access database and display this in another JSPpage
--------------------------------------------------------------------------------
This is my Jsp code for image upload in database:
-----------Upload.jsp----------------
<html>
<head>
<title>Account Details </title>
|
by: Wesley Peace |
last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having
with visual studio 2008.
I've created a series of forms with controls to access a Access database
tables. The connection string works fine and the tables are added to the
project without a problem.
When I create the tables they appear to bind and I am able to preview the
data in the database in design mode; however, at runtime no data is
displayed and the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |