Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.21/5 (4 votes)
hi,
i have problem with creating the database connection in javascript.
if u know the creating the database connection,please share the information.
Thanks in advance.
Posted
Updated 29-Mar-17 6:20am

Have a look here. It's not recommended, it won't work on anything other than IE and it's extremely bad practice,

http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript[^]

Instead of doing this, you should be making your database connections from server-side code (.Net, Java, PHP etc).
 
Share this answer
 
v2
Comments
Member 10512307 23-Jan-14 23:39pm    
what data does "ADODB.Connection" gets? please explain
Member 13411328 20-Sep-17 5:16am    
please explain the working of ADODB.connection
Try this one my friend,

JavaScript
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;


Regards,
Eduard
 
Share this answer
 
Comments
Abhilask kumar 6-Nov-13 6:05am    
I have tried but nothing display .

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