Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
}

</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>
Posted
Updated 26-Jul-11 20:36pm
v3

Take a look at the article here http://www.devarticles.com/c/a/JavaScript/Retrieving-SQL-Server-2000-Constraints-Information-using-Clientside-JavaScript/.

Could be helpful.

However, I strongly suggest you reconsider your approach. You can make an ajax call to get the data from server.
 
Share this answer
 
sir plz give me code and i thank u very much reguarding my question plz give me code to this task sir thank u
 
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