Click here to Skip to main content
12,239,456 members (57,685 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: .NET2.0 Javascript .NET
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 4-Dec-11 22:56pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this one my friend,

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
  Permalink  
Comments
Abhilask kumar 6-Nov-13 6:05am
   
I have tried but nothing display .
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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).
  Permalink  
v2
Comments
Member 10512307 23-Jan-14 23:39pm
   
what data does "ADODB.Connection" gets? please explain

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 5 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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