By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

How To Accesss Ms Sql Databse Usin Activexobject

P: 1
HI,
I AM TRYING TO ACCESS MS SQL 2005 DATABASE THROUGH JAVASCRIPT BUT IT GIVING ME RUNTIME ERROR.


Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type="text/javascript">
  2. <!--
  3. function Aufruf(){
  4. var rst;
  5. var dsn;
  6. var sql;
  7. var newWindow;
  8. try
  9. {
  10. var rst = new ActiveXObject("ADODB.Recordset");
  11. var connection = new ActiveXObject("ADODB.Connection");
  12. connection.Open ("Provider=SQLOLEDB.1;Persist Security Info=False;UserID=myID;Initial Catalog=Projekt;Data Source=MyServer;pwd=mypass");
  13. sql = ("select moiveId, title from movie");
  14. rst.Open (sql, dsn);
  15. newWindow = window.open("","","width=600, height=400,top=200
  16. left=200,scrollbars");
  17. while (!rst.EOF){
  18. newWindow.document.write(rst(0) + " " + rst (1));
  19. newWindow.document.write("<br>");
  20. rst.moveNext();
  21.  
  22. rst.Close();
  23. }
  24. catch{
  25.   txt="There was an error on this page.\n\n"
  26.   txt+="Error description: " + err.description + "\n\n"
  27.   txt+="Click OK to continue.\n\n"
  28.   alert(txt)
  29.   }
Nov 27 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 390
As far I know JavaScript basically being a client side language cannot access a database which is usually in a server. A server side lang such as CGI, PHP, JSP, ASP or similar need to be used. Or you can use AJAX
Nov 27 '07 #2

acoder
Expert Mod 15k+
P: 16,027
HI,
I AM TRYING TO ACCESS MS SQL 2005 DATABASE THROUGH JAVASCRIPT BUT IT GIVING ME RUNTIME ERROR.
What kind of runtime error?

PS. please don't use only caps when typing - it looks like you're shouting!
Nov 27 '07 #3

acoder
Expert Mod 15k+
P: 16,027
As far I know JavaScript basically being a client side language cannot access a database which is usually in a server. A server side lang such as CGI, PHP, JSP, ASP or similar need to be used. Or you can use AJAX
JavaScript can't access a database, but ActiveX can. However, it's only supported by IE.
Nov 27 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.