ASP Retrieve data Problem

18/07/2003 - 22:06 por Wilton | Informe spam
Hello,

I have a problem when I developed the ASP web application
for multiple users to access SQL server 7. Users can
retrieve, insert, update, and delete data. When I retrieve
data sometimes it only can get first row. When I click
refresh button on Internet Explorer all rows come out
sometimes, I checked the coding and couldn't find where
the problem comes from. Also I am not sure the problem
comes from ASP coding or SQL server or IIS.
Here is the coding sample:

<%

'Connect the Database
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=CJ;UID=sa;PWD=;database=northwind"

'SQL Command
SQL="Select CategoryName, CategoryID from Categories "
'run SQL Command
Set RS=Conn.Execute(SQL)

'Appear result

Response.write "<table Align=center border=1
cellpadding=0 cellspacing=0 widthp0>"
Response.write "<tr >"
Response.write "<td colspan=2><B>" & Ucase(rs(0).Name)
& "</B></td>"
Response.write "<td colspan=2><B>" & Ucase(rs(1).Name)
& "</B></td>"
Response.write "</tr>"

do While Not rs.EOF
Response.write "<tr>"
Response.write "<td colspan=2><b>" & rs(0).Value
&"</B></td>"
Response.write "<td colspan=2><b>" & rs(1).Value
&"</B></td>"
Response.write "</tr>"
rs.MoveNext
loop
Response.write "</table>"

Set Conn = nothing
%>

Thanks in advance
 

Leer las respuestas

#1 Miguel Gonzalez
21/07/2003 - 14:11 | Informe spam
Try to create a recordset... and put in SQL a forced ORDER BY:

<%
'Connect the Database
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=CJ;UID=sa;PWD=;database=northwind"
Set rs = Server.CreateObject("ADODB.Recordset")
SQL="Select CategoryName, CategoryID from Categories ORDER BY CategoryID "
rs.Open SQL, Conn, 3, 3
If rs.RecordCount > 0 Then
rs.MoveFirst
' Table headers here...
Do While Not rs.EOF
' Rows here...
rs.MoveNext
Loop
Else
Response.Write("No Data")
End If
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing
%>

Bye!
Miguel

"Wilton" escribió en el mensaje
news:017f01c34d68$161183d0$
Hello,

I have a problem when I developed the ASP web application
for multiple users to access SQL server 7. Users can
retrieve, insert, update, and delete data. When I retrieve
data sometimes it only can get first row. When I click
refresh button on Internet Explorer all rows come out
sometimes, I checked the coding and couldn't find where
the problem comes from. Also I am not sure the problem
comes from ASP coding or SQL server or IIS.
Here is the coding sample:

<%

'Connect the Database
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=CJ;UID=sa;PWD=;database=northwind"

'SQL Command
SQL="Select CategoryName, CategoryID from Categories "
'run SQL Command
Set RS=Conn.Execute(SQL)

'Appear result

Response.write "<table Align=center border=1
cellpadding=0 cellspacing=0 widthp0>"
Response.write "<tr >"
Response.write "<td colspan=2><B>" & Ucase(rs(0).Name)
& "</B></td>"
Response.write "<td colspan=2><B>" & Ucase(rs(1).Name)
& "</B></td>"
Response.write "</tr>"

do While Not rs.EOF
Response.write "<tr>"
Response.write "<td colspan=2><b>" & rs(0).Value
&"</B></td>"
Response.write "<td colspan=2><b>" & rs(1).Value
&"</B></td>"
Response.write "</tr>"
rs.MoveNext
loop
Response.write "</table>"

Set Conn = nothing
%>

Thanks in advance

Preguntas similares