How to get table from sql to htmltable using javascript
hi everybody,
i have taken a html page my task was i have taken a button and table in html page ,my task is "when clicked on button table in sqlserver must display in html table using javascript" (plz help me with code i tried a lot)
my code is follows:
function getsqltable() {
var connection = new ActiveXObject("ADODB.Connection");
var connectionstring = "Data Source=xxxxxx;Initial Catalog=xxxx;User ID=sa;Password=xxxx;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;
}
Collapse
</script>
</head>
<body>
<input id="Button1" önclick="getsqltable();" type="button" value="button" />
<table style="width:26%; height: 180px;">
<tr>
<td>
</td>
<td id="table1">
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</body>
</html>