[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2003-11-10
8
Medium Priority
?
282 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

656 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