-2

I have some database queries whom's data needs to be displayed over the html in the form of tables and graphs

<script>
    var objConnection = new ActiveXObject("adodb.connection");
    var strConn = "driver={sql server};server=ip;database=databasename;uid=username;password=password”;
    objConnection.Open(strConn);
    var rs = new ActiveXObject("ADODB.Recordset");
    var strQuery = "SELECT TOP 10 * FROM dbo.nodes";
    rs.Open(strQuery, objConnection);
    rs.MoveFirst();
    while (!rs.EOF) {
                document.write(rs.fields(0) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(1) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(2) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(3) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(4) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(5) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(6) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(7) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(8) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(9) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(10) + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                document.write(rs.fields(11) + "<br/>");
     rs.movenext();
    }
</script>
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    Hello there and welcome to stack overflow! Usually, you'll receive better answers if you in a clear manner elaborate on the context of your question as well as what you've tried, where you got stuck and what you're looking to achieve. – simme Aug 07 '19 at 11:39

1 Answers1

0

You can generate html report in the database side and simply display the generated html in the web application.

You can use FOR XML Clause to generate HTML report.

There are many samples provided in the Generating HTML reports using SQL Queries article

Also refer to below stackoverflow answers.

-how do I convert a select statement result into an HTML table in SQL Server?
- Convert a SQL query result table to an HTML table for email

Venkataraman R
  • 12,181
  • 2
  • 31
  • 58