how to retrive data from different Ms Access tables using ASP

Reply

Join Date: Jan 2007
Posts: 21
Reputation: nehashri is an unknown quantity at this point 
Solved Threads: 0
nehashri nehashri is offline Offline
Newbie Poster

how to retrive data from different Ms Access tables using ASP

 
0
  #1
May 25th, 2007
hi
i have a problem if any one can help me please. i have 2 tables in Access database- Drug_Name and Chemistry. i have to retrive the from DB to the ASP. the Drug_Name has Drug_ID, D_name, Synonyms as the fields. once the user write a name it should check to the Drug_Name with the Synonyms fields and then with help of Drug_ID it should retrive D_name from Drug_Name table and other fields from Chemistry table.....
the code i used is :-
  1. <HTML>
  2. <BODY>
  3. <%
  4. Actionvar=Request.QueryString("actionvar")
  5. strURL = Request.ServerVariables("URL")
  6. strSearch = Request.form("search")
  7. %>
  8. <p>Search our sample db by first or last name. (% returns all)</p>
  9. <form action="<%= strURL %>" method="post">
  10. <input type = "text" name="search" size = "30" value="<%= strSearch %>" />
  11. <input type="submit" />
  12. </form>
  13. <%
  14. If strSearch <> "" Then
  15. Set conn = server.createobject("adodb.connection")
  16. DSNtemp = "DRIVER={Microsoft Access Driver (*.mdb)}; "
  17. DSNtemp=dsntemp & "DBQ=" & server.mappath("Databases/nprcDrugsDB.mdb")
  18. conn.Open DSNtemp
  19.  
  20. strSQL= "SELECT * FROM Drug_Name, Chemistry WHERE Drug_Name.Drug_ID = Chemistry.Drug_ID And
  21. Drug_Namerequest.form("search")Search, "'", "''") & "'"
  22. response.write sql & "<br>" & vbNewLine
  23.  
  24. set rstSearch = conn.execute(strSQL)
  25. %>
  26. <table border="1">
  27. <tr>
  28. <th>Name</th>
  29. <th>Salts</th>
  30. </tr>
  31. <%
  32. Do While Not rstSearch.EOF
  33. %>
  34. <tr>
  35. <td><%= rstSearch.Fields("D_Name").Value %></td>
  36. <td><%= rstSearch.Fields("S").Value %></td>
  37. </tr>
  38. <%
  39. rstSearch.MoveNext
  40. Loop
  41.  
  42. %>
  43. </table>
  44. <%
  45.  
  46. rstSearch.Close
  47. conn.Close
  48. Set conn = nothing
  49.  
  50. End If
  51. %>
  52. </BODY>
  53. </HTML>

here only the html codes works but ASP codes dont work
i believe that SQL query is correct must be retrival ASP code is not correct
plz help
thanks
neha
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 6
Reputation: Sitestepper is an unknown quantity at this point 
Solved Threads: 0
Sitestepper's Avatar
Sitestepper Sitestepper is offline Offline
Newbie Poster

Re: how to retrive data from different Ms Access tables using ASP

 
0
  #2
May 30th, 2007
Can you show us the result of the response.write sql statement
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 21
Reputation: nehashri is an unknown quantity at this point 
Solved Threads: 0
nehashri nehashri is offline Offline
Newbie Poster

Re: how to retrive data from different Ms Access tables using ASP

 
0
  #3
Jun 7th, 2007
HEy this code is now working asp codes had some problem thanks for reply
neha
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 53
Reputation: Hellodear is an unknown quantity at this point 
Solved Threads: 0
Hellodear's Avatar
Hellodear Hellodear is offline Offline
Junior Poster in Training

Re: how to retrive data from different Ms Access tables using ASP

 
0
  #4
Jun 9th, 2007
Hi neha,
Can you show the right code?

retrieving data from two databases... i'm also in a way to display like that.... can you help me out in this regards.??
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 6
Reputation: MohitB is an unknown quantity at this point 
Solved Threads: 0
MohitB's Avatar
MohitB MohitB is offline Offline
Newbie Poster

Re: how to retrive data from different Ms Access tables using ASP

 
0
  #5
Jun 9th, 2007
hi,
your code is right but the query is not giving any result check your query in access.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC