Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET2.0Javascript
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 21:56pm
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 at 23-Jan-14 23:39pm
   
what data does "ADODB.Connection" gets? please explain
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 at 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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 800
1 OriginalGriff 503
2 Abhinav S 253
3 thatraja 245
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,282
1 OriginalGriff 4,750
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


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