problem with ASP page

problem with ASP page

am 10.06.2006 00:48:30 von Kal

Hi,

I wrote a basic asp page to do a simple 'select' from an ACCESS
database. When I run the page, it just hangs and hangs. What am I doing
wrong?

I am using ACCESS 2003 and I don't know what version of ASP I am
running but its NOT asp.net. It is whatever is supported with IIS 6.0.
below is my code:

thank you:

<%@ LANGUAGE="vbscript" %>




Metrics


<%

'Create the object
set metricsDB = Server.CreateObject("ADODB.Connection")
strSQL = "SELECT [Issue ID] FROM QPTActions"
'Open the connection
metricsDB.Open "metrics"
set itemSet = Server.CreateObject("ADODB.RecordSet")
itemSet.Open strSQL, metricsDB, adOpenForwardOnly

if Not itemSet.EOF then
%>

<%=itemSet.Fields("").Value%>


<%
itemSet.MoveNext
end if
'Close recordset
itemSet.Close
set itemSet = Nothing
'Close the connection
metricsDB.Close
'Destroy the connection
set metricsDB = Nothing
%>


Re: problem with ASP page

am 10.06.2006 11:14:51 von Mike Brind

Kal wrote:
> Hi,
>
> I wrote a basic asp page to do a simple 'select' from an ACCESS
> database. When I run the page, it just hangs and hangs. What am I doing
> wrong?
>
> I am using ACCESS 2003 and I don't know what version of ASP I am
> running but its NOT asp.net. It is whatever is supported with IIS 6.0.
> below is my code:
>
> thank you:
>
> <%@ LANGUAGE="vbscript" %>
>
>
>
>
> Metrics
>
>
> <%
>
> 'Create the object
> set metricsDB = Server.CreateObject("ADODB.Connection")
> strSQL = "SELECT [Issue ID] FROM QPTActions"
> 'Open the connection
> metricsDB.Open "metrics"
> set itemSet = Server.CreateObject("ADODB.RecordSet")
> itemSet.Open strSQL, metricsDB, adOpenForwardOnly
>
> if Not itemSet.EOF then
> %>
>
> <%=itemSet.Fields("").Value%>

>
> <%
> itemSet.MoveNext
> end if
> 'Close recordset
> itemSet.Close
> set itemSet = Nothing
> 'Close the connection
> metricsDB.Close
> 'Destroy the connection
> set metricsDB = Nothing
> %>
>

You are not looping through the recordset correctly. In fact you have
no looping code at all.

itemSet.Open strSQL, metricsDB, adOpenForwardOnly

If Not itemSet.EOF Then
Do While Not itemSet.EOF
Response.Write itemSet("Issue ID") & "
"
itemSet.MoveNext
Loop
Else
Response.Write "No Records"
End If

For other, more efficient ways of doing this:

Should I use recordset iteration, or GetRows(), or GetString()?
http://www.aspfaq.com/show.asp?id=2467

Not part of your immediate problem, but you are using a DSN to connect
to your database. You don't really want to be doing this. They are
outdated, inefficient and can be difficult to manage in a hosting
environment. You should use the native OLEDB provider instead:

What should my connection string look like?
http://www.aspfaq.com/show.asp?id=2126

When you have declared and opened your new, improved connection object,
the best way to generate a recordset is to use the execute method of
the connection object:

<%
set metricsDB = Server.CreateObject("ADODB.Connection")
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Path\to\database\somedatabase.mdb"
metricsDB.open strConn

strSQL = "SELECT [Issue ID] FROM QPTActions"

set itemSet = metricsDB.Execute(strSQL)


--
Mike Brind