How to connect to SQL Server database from JavaScript


How to connect to SQL Server database from JavaScript
Using javascript to access databases may harmful for several reasons like bad practice, security issues, etc..  here is an example given below:
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;
For More Information click here

Related Posts

What is the Use of isNaN Function in JavaScript? A Comprehensive Explanation for Effective Input Validation

In the world of JavaScript, input validation is a critical aspect of ensuring that user-provided data is processed correctly. One indispensa...