Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to bind/show data from sql server into a .html page by using javascript,AJAX,jquery but without using c#,php,vb.net etc.... can anyone plz help by posting some reference links or by posting the code itself..
Posted

1 solution

There is a way of doing it but it is really not recommended due to security issues also this code will only work on IE browsers. My question to you is actually why do you need this. The html page is hosted on a webserver anyway so a serverside scripting language should be available to you.


C#
var connection = new ActiveXObject("ADODB.Connection") ;

var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";

connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");

rs.Open("SELECT * FROM table", connection);
rs.MoveFirst
while(!rs.eof)
{
   document.write(rs.fields(1));
   rs.movenext;
}

rs.close;
connection.close;
 
Share this answer
 
Comments
Shitalansu Kabi 30-Oct-14 10:28am    
Thank you :)...Actually i am working..and a client need this to be done...

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