Click here to Skip to main content
14,665,550 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi everybody,
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-xxxxxx;Initial Catalog=xxxxx;User ID=sa;Password=xxxxx;Provider=xxxxx";

            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>

    <p>
        <input id="Button1" type="button" value="button"  önclick="return Button1_onclick()" /></p>
    
    <p>
        <textarea id="TextArea1" cols="20" name="S1" rows="1"></textarea></p>
    <p>
         </p>
    <p>
         </p>
    
</body>
</html>
Posted
Updated 24-Jul-11 23:03pm
v3

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi,

I think your code is not safe.
I sure that every one can see your js code. There you have you connection sting made public.
I can try populate the area from code behind and use js action set visible attribute of textarea component.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi alex banu,
please give me the answer for my task iam a fresher



thanks and reguards,
chv.siram.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100