You shouldn’t use Javascript to access databases for many reasons, but if you really want to do this, here’s an example:
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;
A good way to do this would be using secondary languages such as PHP, Java, etc. NET.
I hope I’ve helped.
You necessarily need a language server side like PHP, Ruby, Python, others... Only with HTML and Javascript is impossible!
– user7261
It is not a broad question, on the contrary, it is an extremely limited question.
– jpklzm
is quite limited what I want.. I ask you to re-evaluate
– Renan Serrão Nogueira