Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, Is there a way to display

Status
Not open for further replies.

Roberti

Technical User
Mar 2, 2001
96
NL
Hello,

Is there a way to display the results of a query on a asp page. I've made a query and would like the results to be displayed in a asp page. Is that possible?

Roberti.
 
Sure!
Since I dont know how familiar you are to ASP we´ll take it step by step:

1. Run your query like this:
-----------------------------------------------
SQL = "Select firstname,lastname from People"
RS.Open SQL,Conn

2. Loop all the records until EOF is true (EOF = End Of File)
-----------------------------------------------
DO WHILE NOT RS.EOF
[ code to execute, eg. Response.Write(RS("firstname")) ]
RS.MoveNext
Loop

3. Close RS

The above example works if you have a declared recordset called RS and a databasen connection declared as Conn.
If you have that the code will print all the first names in the table People (my example that is =) )

Good luck!

 
Whell, I have a qry in access from wich I want the results displayed in a table. I've got a working code, but that is for ASP.net, and the server on wich it must run doesn.t support asp.net, And i'm unsuccesfull of converting the code to ASP. The asp.net code is:


<%@ Import Namespace=&quot;System.Data.OLEDB&quot; %>
<%@ Page Language=&quot;VB&quot; Debug=&quot;true&quot; %>

<script language=&quot;VB&quot; runat=&quot;server&quot;>

Sub Page_Load(Src As Object, E As EventArgs)
Dim strConn as string =&quot;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=&quot; & server.mappath(&quot;\Database\Storingsformulier.mdb&quot;) & &quot;;&quot;
Dim strSQL as string =&quot;select * from qry_test&quot;
Dim Conn as New OLEDBConnection(strConn)
Dim Cmd as New OLEDBCommand(strSQL,Conn)
Conn.Open()
myDataGrid.DataSource = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
myDataGrid.DataBind()
End Sub

</script>

<html>
<head><title>Test</title></head>
<body bgcolor=&quot;#FFFFFF&quot;>
<font face=&quot;Verdana&quot;><h3>Test</h3></font>
<ASP:DataGrid id=&quot;MyDataGrid&quot; runat=&quot;server&quot;
Width=&quot;100%&quot;
BackColor=&quot;white&quot;
BorderColor=&quot;black&quot;
ShowFooter=&quot;false&quot;
CellPadding=3
CellSpacing=&quot;0&quot;
Font-Name=&quot;Verdana&quot;
Font-Size=&quot;8pt&quot;
Headerstyle-BackColor=&quot;lightblue&quot;
Headerstyle-Font-Size=&quot;10pt&quot;
Headerstyle-Font-Style=&quot;bold&quot;
MaintainState=&quot;false&quot;
/>

</body>
</html>

how the table looks isn't important, just that the results of the query 'qry_test' are shown in a table.

Roberti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top