?
Solved

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

Posted on 2003-11-10
8
Medium Priority
?
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
LVL 58

Accepted Solution

by:
amit_g earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

752 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