Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
task: i have taken a button and table control in html page now my problem is to display sql table in html table control ....
please help me iam a fresher
my code as follows:
.....................................................................................
XML
<script type="text/javascript" language="javascript">

        function getsqltable() {
            var connection = new ActiveXObject("ADODB.Connection");
            var connectionstring = "Data Source=;Initial Catalog=;User ID=sa;Password=;Provider=SQLOLEDB";
            connection.Open(connectionstring);
            var rs = new ActiveXObject("ADODB.Recordset");
            rs.Open("select * from sample", connection);
            rs.MoveFirst
            while (!rs.eof) {
                var tdt = rs.fields(0);
                var tdt2 = tdt + rs.fields(1);
                table1.width = tdt2;
                rs.movenext;
            }
            rs.close;
            connection.close;
        }
    </script>
</head>
<body>
    <input id="Button1" onclick="getsql();" type="button" value="button" />&nbsp;
    <table style="width: 100%;">
        <tr>
            <td id="table1">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td id="table1">
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
    </table>
</body>
</html>
Posted
Updated 26-Jul-11 1:33am
v3

One of these methods:

0) You need another javascript function that can fetch a row from the returned datatable, and then build/return a string that represents the html table row. You would need to make your datatable global.

1) Write another method that accepts a datarow, and then build/return a string that represents the html table row.

2) Just iterate through the datarows and build your html in the method you already have, and return the resulting string.
 
Share this answer
 
sir plz give me the code so as i can do my task iam not understanding like this sir i tried a lot sir plz and thank u for ur kind response reguarding the information u have gave to me
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900