This is a discussion on Connecting Database using Javascript within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi, I want to connect a database from javascript code and to get the records from a table. Can anyone ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, I want to connect a database from javascript code and to get the records from a table. Can anyone give me an idea?
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| Sponsored Links |
| |||
| Hi, Hope this helps.. <html> <head> <SCRIPT LANGUAGE=javascript> function ConDB() { var conn = new ActiveXObject("ADODB.Connection") ; alert(conn); var connectionstring="Data Source=localhost;Initial Catalog=Database1;User ID=ab;Password=123456;Provider=SQLOLEDB"; alert(connectionstring); conn.Open(connectionstring); alert(conn); var rs = new ActiveXObject("ADODB.Recordset"); alert(rs); rs.Open("SELECT * FROM users ", conn); rs.MoveFirst while(!rs.eof) { document.write(rs.fields(1)); rs.movenext; } rs.close; conn.close; } </SCRIPT> </head> <body OnLoad="javascript:ConDB()"> </body> </html>
__________________ S.Balasubramanian Nothing is impossible |
| |||
| <html> <head> <script type="text/javascript"> var conn = new ActiveXObject("ADODB.Connection") var conn_str = "" var dbHost = "" var dbUser = "" var dbPassword = "" var dbProvider = "" var dbDefault = "" function getData() { dbHost = "localhost"; dbUser = "sa"; dbPassword = ""; dbProvider = "SQLOLEDB"; dbDefault = "master"; conn_str = "Provider="+dbProvider+";Data Source="+dbHost+"; User Id="+dbUser+"; password="+dbPassword+"; Initial Catalog="+dbDefault; getDatabase(); } function getDatabase() { try { conn.Open(conn_str) alert(conn) } catch(e) { alert("Error creating Connection") } } </script> </head> <body onload="getData()"> </body> </html> |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| types of object while connecting with mysql | venkatbi | PHP Programming | 0 | 11-22-2007 05:51 AM |
| Connecting Database using PERL | Murali | Perl | 1 | 08-17-2007 12:08 AM |
| Explain Connecting External Hardware to J2ME applications | itbarota | J2ME | 2 | 08-06-2007 09:11 AM |
| Any idea about Connecting Windows Mobile to Wireless HID devices? | itbarota | Windows Mobile | 0 | 07-23-2007 07:12 AM |
| connecting database | nssukumar | Flash Actionscript Programming | 1 | 04-24-2007 11:14 PM |