To display sql table in textarea in html page when button clicked in javascript
Hi everybody,
"question and code follows":
In have added an html page in asp.net website now my task is ::
i have one button and textarea in design part of html page,i want to display sqlserver table data in textarea control when clicked on button using javascript.please tell me the procedure and javascript code to do this task
i have written some code please look at this code as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" language="javascript">
function getsql() {
var connection = new ActiveXObject("ADODB.Connection");
var connectionstring = "Data Source=ajel-f4086fb383;Initial Catalog=sriram;User ID=sa;Password=Ajel;Provider=SQLOLEDB";
connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
rs.Open("SELECT * FROM studenttable", connection);
rs.MoveFirst
while (!rs.eof) {
document.write(rs.fields(0));
document.write(rs.fields(1));
document.write(rs.fields(2));
rs.movenext;
}
rs.close;
connection.close;
}
</script>
<style type="text/css">
#TextArea1
{
height: 40px;
width: 108px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<input id="Button1" type="button" value="button" önclick="return Button1_onclick()" />
<textarea id="TextArea1" cols="20" name="S1" rows="1"></textarea>
</body>
</html>