Solved

Accessing an Access Query that doesn't need parameters passed to it with ASP

Posted on 2003-11-10
8
271 Views
Last Modified: 2010-04-06
I am trying to access a query in an Access database and I need to do it with asp I was wanting the syntax
0
Comment
Question by:Joeba280
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:amit_g
ID: 9719451
Try something like this. Make sure to replace YourAccessFileName and YourQueryName with proper values ...

<%@ Language=VBScript %>
<%option explicit%>
<%
      Response.Buffer = false
%>
<%
      dim oConn, oRs

      sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("YourAccessFileName") & ";User Id=admin;Password=;"

      set oConn = Server.CreateObject("ADODB.Connection")

      Call oConn.Open(sConnectionString)

      set oRs = oConn.Execute("select * from YourQueryName")
%>
<HTML>
<HEAD>
</HEAD>

<BODY>

<%
      Response.Write("<table>")
      while not oRs.EOF
            Response.Write ("<tr>")
            Response.Write ("<td>")
            Response.Write (oRs(0)) 'Here you can also use column name i.e. oRs("ColumnName0")
            Response.Write ("</td>")
            Response.Write ("<td>")
            Response.Write (oRs(1)) 'Here you can also use column name i.e. oRs("ColumnName1")
            Response.Write ("</td>")
            Response.Write ("</tr>")
            Call oRs.MoveNext()
      wend
      Response.Write("</table>")
%>

</BODY>

</HTML>
<%
      set oRs = nothing
      set oConn = nothing
%>
0
 
LVL 1

Author Comment

by:Joeba280
ID: 9719576
I am using a variable for the query name, How would I plug that in here?
0
 
LVL 58

Expert Comment

by:amit_g
ID: 9719582
set oRs = oConn.Execute("select * from " & YourQueryNameVariable)
0
 
LVL 1

Author Comment

by:Joeba280
ID: 9719714
I don't know what is wrong I have put in the code that you gave me but it is now giving me an unspecified error that states on the line where I have the previous connection opening but the funny thing is I have it closed, what could the problem be, I closed the connection and set it equal to nothing.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 58

Accepted Solution

by:
amit_g earned 250 total points
ID: 9719722
Very difficult to guess without seeing the code. Try this in a new asp file to make sure this code is correct. You can combine this code into the first one after you are certain that it works.
0
 
LVL 1

Author Comment

by:Joeba280
ID: 9719776
I modified it a bit but it does work really appreciate it would you mind looking at the code about that other error. if not thats ok
0
 
LVL 58

Expert Comment

by:amit_g
ID: 9724491
I can give it a try if you post the code :)
0
 
LVL 1

Author Comment

by:Joeba280
ID: 9725677
Well I actually got it working I just need to figure out how to repost the data once something has been selected
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now